Comparing version 1.7.1 to 1.8.0
@@ -346,7 +346,7 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */ | ||
? define | ||
: function (deps, factory) { typeof module != 'undefined' | ||
: function (deps, factory) { typeof exports != 'undefined' | ||
? (module.exports = factory(require('./when'))) | ||
: (this.when = factory(this.when)); | ||
: (this.when = factory(this.when)); | ||
} | ||
// Boilerplate for AMD, Node, and browser global | ||
); |
{ | ||
"name": "when", | ||
"version": "1.7.1", | ||
"version": "1.8.0", | ||
"description": "A lightweight Promise and when() implementation, plus other async goodies.", | ||
@@ -5,0 +5,0 @@ "keywords": ["promise", "promises", "deferred", "deferreds", "when", "async", "asynchronous", "cujo"], |
@@ -5,6 +5,12 @@ # when.js [![Build Status](https://secure.travis-ci.org/cujojs/when.png)](http://travis-ci.org/cujojs/when) | ||
It passes the [Promises/A Test Suite](https://github.com/domenic/promise-tests), is [frighteningly fast](https://github.com/cujojs/promise-perf-tests#test-results), and is **under 1.3k** when compiled with Google Closure (w/advanced optimizations) and gzipped, and has no dependencies. | ||
It passes the [Promises/A Test Suite](https://github.com/domenic/promise-tests), is [frighteningly fast](https://github.com/cujojs/promise-perf-tests#test-results), and is **around 1.3k** when compiled with Google Closure (w/advanced optimizations) and gzipped, and has no external dependencies. | ||
# What's New? | ||
### 1.8.0 | ||
* New [when/function](docs/api.md#synchronous-functions), [when/node/function](docs/api.md#node-style-asynchronous-functions), and [when/callbacks](docs/api.md#asynchronous-functions) with functional programming goodness, and adapters for turning callback-based APIs into promise-based APIs. Kudos [@riccieri](https://github.com/riccieri)! | ||
* New [when/unfold](api.md#whenunfold), and [when/unfold/list](api.md#whenunfoldlist) promise-aware anamorphic unfolds that can be used to generate and/or process unbounded lists. | ||
* New [when/poll](api.md#whenpoll) promise-based periodic polling and task execution. Kudos [@scothis](https://github.com/scothis)! | ||
### 1.7.1 | ||
@@ -17,29 +23,16 @@ | ||
* **DEPRECATED:** `deferred.then` [is deprecated](when/blob/master/docs/api.md#deferred) and will be removed in an upcoming release. Use `deferred.promise.then` instead. | ||
* [promise.yield](when/blob/master/docs/api.md#yield)(promiseOrValue) convenience API for substituting a new value into a promise chain. | ||
* [promise.spread](when/blob/master/docs/api.md#spread)(variadicFunction) convenience API for spreading an array onto a fulfill handler that accepts variadic arguments. [Mmmm, buttery](http://s.shld.net/is/image/Sears/033W048977110001_20100422100331516?hei=1600&wid=1600&op_sharpen=1&resMode=sharp&op_usm=0.9,0.5,0,0) | ||
* **DEPRECATED:** `deferred.then` [is deprecated](docs/api.md#deferred) and will be removed in an upcoming release. Use `deferred.promise.then` instead. | ||
* [promise.yield](docs/api.md#yield)(promiseOrValue) convenience API for substituting a new value into a promise chain. | ||
* [promise.spread](docs/api.md#spread)(variadicFunction) convenience API for spreading an array onto a fulfill handler that accepts variadic arguments. [Mmmm, buttery](http://s.shld.net/is/image/Sears/033W048977110001_20100422100331516?hei=1600&wid=1600&op_sharpen=1&resMode=sharp&op_usm=0.9,0.5,0,0) | ||
* Doc improvements: | ||
* [when()](when/blob/master/docs/api.md#when) and [promise.then()](when/blob/master/docs/api.md#main-promise-api) have more info about callbacks and chaining behavior. | ||
* More info and clarifications about the roles of [Deferred](when/blob/master/docs/api.md#deferred) and [Resolver](when/blob/master/docs/api.md#resolver) | ||
* [when()](docs/api.md#when) and [promise.then()](docs/api.md#main-promise-api) have more info about callbacks and chaining behavior. | ||
* More info and clarifications about the roles of [Deferred](docs/api.md#deferred) and [Resolver](docs/api.md#resolver) | ||
* Several minor clarifications for various APIs | ||
* Internal improvements to assimilation and interoperability with other promise implementations. | ||
### 1.6.1 | ||
[Full Changelog](CHANGES.md) | ||
* Fix for accidental coercion of non-promises. See [#62](https://github.com/cujojs/when/issues/60). | ||
### 1.6.0 | ||
* New [when.join](when/blob/master/docs/api.md#whenjoin) - Joins 2 or more promises together into a single promise. | ||
* [when.some](when/blob/master/docs/api.md#whensome) and [when.any](when/blob/master/docs/api.md#whenany) now act like competitive races, and have generally more useful behavior. [Read the discussion in #60](https://github.com/cujojs/when/issues/60). | ||
* *Experimental* progress event propagation. Progress events will propagate through promise chains. [Read the details here](when/blob/master/docs/api.md#progress-events). | ||
* *Temporarily* removed calls to `Object.freeze`. Promises are no longer frozen due to a horrendous v8 performance penalty. [Read discussion here](https://groups.google.com/d/topic/cujojs/w_olYqorbsY/discussion). | ||
* **IMPORTANT:** Continue to treat promises as if they are frozen, since `freeze()` will be reintroduced once v8 performance improves. | ||
* [when/debug](https://github.com/cujojs/when/wiki/when-debug) now allows setting global a debugging callback for rejected promises. | ||
[Full Changelog](https://github.com/cujojs/when/wiki/Changelog) | ||
# Docs & Examples | ||
[API docs](when/blob/master/docs/api.md#api) | ||
[API docs](docs/api.md#api) | ||
@@ -46,0 +39,0 @@ [More info on the wiki](https://github.com/cujojs/when/wiki) |
26
when.js
@@ -1,2 +0,2 @@ | ||
/** @license MIT License (c) copyright B Cavalier & J Hann */ | ||
/** @license MIT License (c) copyright 2011-2013 original author or authors */ | ||
@@ -10,3 +10,6 @@ /** | ||
* | ||
* @version 1.7.1 | ||
* @author Brian Cavalier | ||
* @author John Hann | ||
* | ||
* @version 1.8.0 | ||
*/ | ||
@@ -160,3 +163,3 @@ | ||
*/ | ||
yield: function(value) { | ||
'yield': function(value) { | ||
return this.then(function() { | ||
@@ -170,3 +173,3 @@ return value; | ||
* for the onFulfilled to be called with the array as its argument list | ||
* i.e. onFulfilled.spread(undefined, array). | ||
* i.e. onFulfilled.apply(undefined, array). | ||
* @param {function} onFulfilled function to receive spread arguments | ||
@@ -194,5 +197,4 @@ * @return {Promise} | ||
var p = new Promise(function(onFulfilled) { | ||
// TODO: Promises/A+ check typeof onFulfilled | ||
try { | ||
return resolve(onFulfilled ? onFulfilled(value) : value); | ||
return resolve(typeof onFulfilled == 'function' ? onFulfilled(value) : value); | ||
} catch(e) { | ||
@@ -216,5 +218,4 @@ return rejected(e); | ||
var p = new Promise(function(_, onRejected) { | ||
// TODO: Promises/A+ check typeof onRejected | ||
try { | ||
return onRejected ? resolve(onRejected(reason)) : rejected(reason); | ||
return resolve(typeof onRejected == 'function' ? onRejected(reason) : rejected(reason)); | ||
} catch(e) { | ||
@@ -281,3 +282,2 @@ return rejected(e); | ||
_then = function(onFulfilled, onRejected, onProgress) { | ||
// TODO: Promises/A+ check typeof onFulfilled, onRejected, onProgress | ||
var deferred, progressHandler; | ||
@@ -326,4 +326,2 @@ | ||
_resolve = function(value) { | ||
value = resolve(value); | ||
// Replace _then with one that directly notifies with the result. | ||
@@ -334,3 +332,3 @@ _then = value.then; | ||
// Make _progress a noop, to disallow progress for the resolved promise. | ||
_progress = noop; | ||
_progress = identity; | ||
@@ -364,3 +362,3 @@ // Notify handlers | ||
function promiseResolve(val) { | ||
return _resolve(val); | ||
return _resolve(resolve(val)); | ||
} | ||
@@ -463,3 +461,3 @@ | ||
return deferred.then(onFulfilled, onRejected, onProgress); | ||
return deferred.promise.then(onFulfilled, onRejected, onProgress); | ||
@@ -466,0 +464,0 @@ function rejecter(reason) { |
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
86757
23
2072
96