Comparing version 0.1.8 to 0.1.9
@@ -0,1 +1,5 @@ | ||
#0.1.9 / 2012-09-22 | ||
* Change comb.array.intersection to not use recursion | ||
* added `comb.wait` | ||
#0.1.8/2012-09-10 | ||
@@ -2,0 +6,0 @@ * Added travis CI build |
@@ -760,2 +760,43 @@ var hitch = require("./base/functions").hitch, | ||
/** | ||
* Ensures that a promise is resolved before a the function can be run. | ||
* | ||
* For example suppose you have to ensure that you are connected to a database before you execute a function. | ||
* | ||
* ``` | ||
* var findUser = comb.wait(connect(), function findUser(id){ | ||
* //this wont execute until we are connected | ||
* return User.findById(id); | ||
* }); | ||
* | ||
* comb.when(findUser(1), findUser(2)).then(function(users){ | ||
* var user1 = users[0], user2 = users[1]; | ||
* }); | ||
* | ||
* ``` | ||
* | ||
* @param args variable number of arguments to wait on. See {@link comb.when}. | ||
* @param {Function} fn function that will wait. | ||
* @return {Function} a function that will wait on the args to resolve. | ||
* @memberOf comb | ||
* @static | ||
*/ | ||
function wait(args, fn) { | ||
var args = argsToArray(arguments), resolved = false; | ||
fn = args.pop(); | ||
var p = when(args); | ||
return function waiter() { | ||
if (!resolved) { | ||
args = arguments; | ||
return p.chain(function doneWaiting() { | ||
resolved = true; | ||
return fn.apply(this, args); | ||
}.bind(this)); | ||
} else { | ||
return when(fn.apply(this, arguments)); | ||
} | ||
} | ||
} | ||
base.merge(exports, { | ||
@@ -765,2 +806,3 @@ isPromiseLike:isPromiseLike, | ||
wrap:wrap, | ||
wait:wait, | ||
serial:serial, | ||
@@ -767,0 +809,0 @@ chain:chain, |
{ | ||
"name":"comb", | ||
"description":"A framework for node", | ||
"version":"0.1.8", | ||
"version":"0.1.9", | ||
"keywords":["OO", "Object Oriented", "Collections", "Tree", "HashTable", "Pool", "Logging", "Promise", "Promises", "Proxy"], | ||
@@ -16,7 +16,7 @@ "repository":{ | ||
}, | ||
"devDependencies" : { | ||
"it": "0.0.5" | ||
"devDependencies":{ | ||
"it":"0.0.5" | ||
}, | ||
"scripts": { | ||
"test": "make test-travis" | ||
"scripts":{ | ||
"test":"make test-travis" | ||
}, | ||
@@ -23,0 +23,0 @@ "engines":{ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1633623
11296