Skip to content

Commit

Permalink
Return updated values on insert and trigger.
Browse files Browse the repository at this point in the history
  • Loading branch information
vaneenige committed Mar 7, 2018
1 parent b295bc1 commit b3ff630
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ server.get(route, (req, res) => {

_Inserts a tracker into the vault._

Returns: Result of update function (use await for async updates).

### .trigger(key)

_Manually runs a tracker._

Returns: Result of update function (use await for async updates).

### .prototype

As `unvault` extends [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map), all of its functions are available: `clear()`, `delete(key)`, `entries()` and more!
Expand Down
5 changes: 3 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ class Unvault extends Map {
* @param {function} update
* @param {object} options
*/
insert(key, interval, update, options) {
async insert(key, interval, update, options) {
this.set(key, { interval, update, ...options });
this.trigger(key, interval !== 0);
return this.trigger(key, interval !== 0);
}

/**
Expand Down Expand Up @@ -37,6 +37,7 @@ class Unvault extends Map {
this.trigger(key, automated);
}, tracker.interval);
}
return value;
}
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "unvault",
"version": "0.3.0",
"version": "0.4.0",
"description": "A minimal layer for node that allows results of time-consuming tasks to be stored.",
"repository": "vaneenige/unvault",
"main": "lib/index.js",
Expand Down

0 comments on commit b3ff630

Please sign in to comment.