Comparing version 2.2.0 to 2.2.1
@@ -61,2 +61,10 @@ /** @license MIT License (c) copyright 2013 original author or authors */ | ||
function apply(asyncFunction, extraAsyncArgs) { | ||
return _apply(asyncFunction, this, extraAsyncArgs); | ||
} | ||
/** | ||
* Apply helper that allows specifying thisArg | ||
* @private | ||
*/ | ||
function _apply(asyncFunction, thisArg, extraAsyncArgs) { | ||
return when.all(extraAsyncArgs || []).then(function(args) { | ||
@@ -69,3 +77,3 @@ return promise(function(resolve, reject) { | ||
asyncFunction.apply(null, asyncArgs); | ||
asyncFunction.apply(thisArg, asyncArgs); | ||
}); | ||
@@ -96,4 +104,3 @@ }); | ||
function call(asyncFunction/*, arg1, arg2...*/) { | ||
var extraAsyncArgs = slice.call(arguments, 1); | ||
return apply(asyncFunction, extraAsyncArgs); | ||
return _apply(asyncFunction, this, slice.call(arguments, 1)); | ||
} | ||
@@ -130,12 +137,10 @@ | ||
* | ||
* @param {Function} asyncFunction traditional function to be decorated | ||
* @param {Function} f traditional async function to be decorated | ||
* @param {...*} [args] arguments to be prepended for the new function | ||
* @returns {Function} a promise-returning function | ||
*/ | ||
function lift(asyncFunction/*, args...*/) { | ||
var leadingArgs = slice.call(arguments, 1); | ||
function lift(f/*, args...*/) { | ||
var args = slice.call(arguments, 1); | ||
return function() { | ||
var trailingArgs = slice.call(arguments, 0); | ||
return apply(asyncFunction, leadingArgs.concat(trailingArgs)); | ||
return _apply(f, this, args.concat(slice.call(arguments))); | ||
}; | ||
@@ -195,2 +200,3 @@ } | ||
return function() { | ||
var thisArg = this; | ||
return when.all(arguments).then(function(args) { | ||
@@ -218,3 +224,3 @@ return promise(applyPromisified); | ||
asyncFunction.apply(null, args); | ||
asyncFunction.apply(thisArg, args); | ||
} | ||
@@ -244,5 +250,5 @@ | ||
if(arguments.length <= 1) { | ||
fn.apply(null, arguments); | ||
fn.apply(this, arguments); | ||
} else { | ||
fn.call(null, slice.call(arguments, 0)); | ||
fn.call(this, slice.call(arguments)); | ||
} | ||
@@ -249,0 +255,0 @@ }; |
@@ -0,1 +1,7 @@ | ||
### 2.2.1 | ||
* Fix for `when.defer().reject()` bypassing the unhandled rejection monitor. (#166) | ||
* Fix for `when/function`, `when/callbacks`, and `when/node/function` not preserving `thisArg`. (#162) | ||
* Doc clarifications for [`promise.yield`](docs/api.md#yield). (#164) | ||
### 2.2.0 | ||
@@ -2,0 +8,0 @@ |
@@ -54,7 +54,14 @@ /** @license MIT License (c) copyright 2013 original author or authors */ | ||
function apply(func, promisedArgs) { | ||
return _apply(func, this, promisedArgs); | ||
} | ||
/** | ||
* Apply helper that allows specifying thisArg | ||
* @private | ||
*/ | ||
function _apply(func, thisArg, promisedArgs) { | ||
return when.all(promisedArgs || [], function(args) { | ||
return func.apply(null, args); | ||
return func.apply(thisArg, args); | ||
}); | ||
} | ||
/** | ||
@@ -86,3 +93,3 @@ * Has the same behavior that {@link apply} has, with the difference that the | ||
function call(func /*, args... */) { | ||
return apply(func, slice.call(arguments, 1)); | ||
return _apply(func, this, slice.call(arguments, 1)); | ||
} | ||
@@ -133,3 +140,3 @@ | ||
return function() { | ||
return apply(func, args.concat(slice.call(arguments))); | ||
return _apply(func, this, args.concat(slice.call(arguments))); | ||
}; | ||
@@ -190,7 +197,10 @@ } | ||
return function() { | ||
var args = slice.call(arguments); | ||
var firstPromise = apply(f, args); | ||
var thisArg, args, firstPromise; | ||
thisArg = this; | ||
args = slice.call(arguments); | ||
firstPromise = _apply(f, thisArg, args); | ||
return when.reduce(funcs, function(arg, func) { | ||
return func(arg); | ||
return func.call(thisArg, arg); | ||
}, firstPromise); | ||
@@ -197,0 +207,0 @@ }; |
@@ -62,2 +62,10 @@ /** @license MIT License (c) copyright 2013 original author or authors */ | ||
function apply(func, args) { | ||
return _apply(func, this, args); | ||
} | ||
/** | ||
* Apply helper that allows specifying thisArg | ||
* @private | ||
*/ | ||
function _apply(func, thisArg, args) { | ||
return when.all(args || []).then(function(resolvedArgs) { | ||
@@ -67,3 +75,3 @@ var d = when.defer(); | ||
func.apply(null, resolvedArgs.concat(callback)); | ||
func.apply(thisArg, resolvedArgs.concat(callback)); | ||
@@ -100,3 +108,3 @@ return d.promise; | ||
function call(func /*, args... */) { | ||
return apply(func, slice.call(arguments, 1)); | ||
return _apply(func, this, slice.call(arguments, 1)); | ||
} | ||
@@ -137,3 +145,3 @@ | ||
return function() { | ||
return apply(func, args.concat(slice.call(arguments))); | ||
return _apply(func, this, args.concat(slice.call(arguments))); | ||
}; | ||
@@ -140,0 +148,0 @@ } |
{ | ||
"name": "when", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"description": "A lightweight Promises/A+ and when() implementation, plus other async goodies.", | ||
@@ -54,3 +54,3 @@ "keywords": ["Promises/A+", "promises-aplus", "promise", "promises", "deferred", "deferreds", "when", "async", "asynchronous", "cujo"], | ||
"test": "jshint . && buster test -e node && promises-aplus-tests test/promises-aplus-adapter.js", | ||
"ci": "npm test && sauceme", | ||
"ci": "npm test", | ||
"tunnel": "sauceme -m", | ||
@@ -57,0 +57,0 @@ "start": "buster static -e browser", |
@@ -18,5 +18,11 @@ <a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" alt="Promises/A+ logo" align="right" /></a> | ||
### 2.2.1 | ||
* Fix for `when.defer().reject()` bypassing the unhandled rejection monitor. (#166) | ||
* Fix for `when/function`, `when/callbacks`, and `when/node/function` not preserving `thisArg`. (#162) | ||
* Doc clarifications for [`promise.yield`](docs/api.md#yield). (#164) | ||
### 2.2.0 | ||
* New experimental [promise monitoring and debugging](docs.md#debugging-promises) via `when/monitor/console`. | ||
* New experimental [promise monitoring and debugging](docs/api.md#debugging-promises) via `when/monitor/console`. | ||
* New [`when.promise(resolver)`](docs/api.md#whenpromise) promise creation API. A lighter alternative to the heavier `when.defer()` | ||
@@ -23,0 +29,0 @@ * New `bindCallback` and `liftCallback` in `when/node/function` for more integration options with node-style callbacks. |
@@ -12,3 +12,3 @@ /** @license MIT License (c) copyright 2011-2013 original author or authors */ | ||
* @author John Hann | ||
* @version 2.2.0 | ||
* @version 2.2.1 | ||
*/ | ||
@@ -193,3 +193,3 @@ (function(define, global) { 'use strict'; | ||
deferred.promise = pending = _promise(makeDeferred); | ||
deferred.promise = pending = promise(makeDeferred); | ||
@@ -196,0 +196,0 @@ return deferred; |
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
122065
3110
135