Skip to content

Commit

Permalink
set method
Browse files Browse the repository at this point in the history
  • Loading branch information
rook2pawn committed Apr 29, 2014
1 parent 6776b4c commit ccf685f
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 2 deletions.
21 changes: 20 additions & 1 deletion README.md
Expand Up @@ -2,7 +2,7 @@

New!
====
Key value store across series!
Key value store across series! Just call .done(hash) to store the keys/values of the hash

queue.series([
function(lib) {
Expand All @@ -17,6 +17,25 @@ Key value store across series!
}
]);


You can also use .set(hash)

queue.series([
function(lib) {
lib.set({one:1});
lib.done()
},
function(lib) {
lib.set({life:42})
lib.done()
},
function(lib) {
t.equal(43,lib.get('one') + lib.get('life'));
lib.done();
}
]);


New!
====
Early termination flow control in .series!
Expand Down
6 changes: 6 additions & 0 deletions index.js
Expand Up @@ -90,6 +90,12 @@ function qlib(myWorkFunction) {
this.hash = {};
this.get = function(key) {
return this.hash[key];
}
this.set = function(obj) {
if ((obj) && (typeof obj == 'object')) {
Hash(this.hash).update(obj);
}
return true;
}
this.done = function(obj) {
if ((obj) && (typeof obj == 'object')) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -2,7 +2,7 @@
"author": "David Wee <rook2pawn@gmail.com> (http://rook2pawn.com)",
"name": "queuelib",
"description": "Straightforward asynchronous queue processor",
"version": "0.3.5",
"version": "0.3.6",
"homepage": "https://github.com/rook2pawn/node-queuelib",
"repository": {
"type": "git",
Expand Down
22 changes: 22 additions & 0 deletions test/test-set.js
@@ -0,0 +1,22 @@

var test = require('tape');

test('testSet',function(t) {
t.plan(1);
var Q = require('../');
var queue = new Q;
queue.series([
function(lib) {
lib.set({one:1});
lib.done()
},
function(lib) {
lib.set({life:42})
lib.done()
},
function(lib) {
t.equal(43,lib.get('one') + lib.get('life'));
lib.done();
}
]);
});

0 comments on commit ccf685f

Please sign in to comment.