when/keys settle
, for settling a hash of promises.poly
from npm instead of a git link in package.json. No need for git to be available to npm install when.monitor/console
in IE8.npm publish
did not include the file poll.js
when publishing 3.7.1when.settle
unhandled rejection reporting case.process
and window
unhandled rejection events for cross-library debugging tools.null
errors in unhandled rejection reportingwhen/callbacks
introduced in 3.6.1when.filter
and when.reduce
(which also affected when/sequence
).when.try
, and when.lift
.when.reduce
, when.any
, and when.some
.when.all
, when.map
, and when.any
.when.map
, especially for large arrayswhen.reduce
and promise.fold
when/generator
lift
, call
, and/or apply
.when.reduce
and promise.fold
.console.*
calls. Unhandled rejections will be reported even when using Uglify drop_console
.when/function.apply
now handles passing an Arguments object directly, e.g. fn.apply(f, arguments);
. Use with care: v8 will deoptimize any function where you pass arguments
to another function.when.race
& Promise.race
now reject with a TypeError
if you pass something that is not iterable.when.race
& Promise.race
performance.when.iterate
and when.unfold
. Use cujoJS/most for streaming asynchronous values.vertx
from browser bundlespromise.finally
not waiting on returned promises.when.filter
for filtering arrays of promises.when.map
and when.filter
now provide the array index as the second param to their mapping and filtering functions.when/keys.map
now provides the associated key to its mapping function.when/node
introduced in 3.3.0.when.race
to public API.when.any
and when.some
now reject with a RangeError
if the race is obviously unwinnable, for example: when.some([1,2,3], 4)
. See the when.any
and when.some
docs for more info.when.all
JSON.stringify
exceptions when formatting unhandled rejection output.console.error
by default, even without using done
or when/monitor/console
. As before, enabling when/monitor/console
still adds long async stack traces, and using done
still makes errors fatal. See Debugging Promises for more info.promise.timeout
now rejects with a TimeoutError
by default (unless you specify a custom reason) for better pattern matching with promise.catch
.when.all
(and Promise.all
in the ES6-shim) and node.lift
: lifted functions and lifting are faster now.promise.fold
for combining two promises to generate a new promise.when/node.lift
, when/function.lift
, and when/callbacks.lift
to provide partial argumentspromise.then
's 3rd argument, and when()
's 4th argument. Use the dedicated promise.progress
API to listen to promise progress events.when.some
. See https://github.com/cujojs/when/issues/288when/callbacks.promisify
See https://github.com/cujojs/when/issues/318reason
param to promise.timeout
to specify your own timeout value.when.all
(and es6-shim Promise.all
)when/monitor/console
long stack trace improvements. Traces can track nested async functions even if you forget to return a promise.var promisedFs = node.liftAll(require('fs'))
when.Promise
public, inheritance-friendly, Promise constructorwhen/generator
module, with lift
, call
, apply
.promise.catch
and promise.finally
as synonyms for promise.otherwise
and promise.ensure
. (#212)package.json
. (#223)bower.json
ignore
to trim files installed via bower. (#193)promise.done
allows consuming the ultimate value at the end of a promise chain while ensuring that any errors are thrown to the host environment so you get loud stack traces.when/node/function
bindCallback
and liftCallback
now behave more like standard node-style APIs in that they allow exceptions to propagate to the host environment for loud stack traces.ensure
now ignores non-functions, like then
does, for consistency. (#207)MutationObserver
scheduler further reduces "time-to-first-handler" in modern browsers. (#198)
setImmediate
, MessageChannel
, and postMessage
unusable as fast task schedulers. Many thanks to @plaa and @calvinmetcalf for their help in discovering the problem and working out a solution. (#197)when.isPromiseLike
as the more accurately-named synonym for when.isPromise
.when.isPromise
. It can only tell you that something is "promise-like" (aka "thenable") anyway. Use the new, more accurately-named when.isPromiseLike
instead.when.all
and when.map
.promise.tap
for adding side effects to a promise chain.MessageChannel
scheduler reduces "time-to-first" handler, in environments that support it.when.defer().reject()
bypassing the unhandled rejection monitor. (#166)when/function
, when/callbacks
, and when/node/function
not preserving thisArg
. (#162)promise.yield
. (#164)when/monitor/console
.when.promise(resolver)
promise creation API. A lighter alternative to the heavier when.defer()
bindCallback
and liftCallback
in when/node/function
for more integration options with node-style callbacks.promise.yield
to workaround .NET minifier tools that don't yet understand ES5 identifier-as-property rules. See #157when.settle
that settles an array of promises, regardless of whether the fulfill or reject.when/guard
generalized concurrency guarding and limitingpromise.inspect
for synchronously getting a snapshot of a promise's state at a particular instant.onFulfilled
, onRejected
, onProgress
handler arguments to when.all
, when.any
, when.some
. Use the returned promise's then()
(or otherwise()
, ensure()
, etc) to register handlers instead.
when.all(array).then(onFulfilled, onRejected)
instead of this: when.all(array, onFulfilled, onRejected)
. The functionality is equivalent.process
. Thanks Narsulwhen/keys
module with all()
and map()
for object keys/values.promise.ensure
as a better, and safer, replacement for promise.always
. See discussion as to why promise.always
is mistake-prone.
promise.always
lift()
is now the preferred name for what was bind()
in when/function, when/node/function, and when/callbacks.
bind()
in when/function
, when/node/function
, and when/callbacks
. Use lift()
instead.deferred.progress
and deferred.resolver.progress
. Use deferred.notify
and deferred.resolver.notify
instead.when.chain
. Use resolver.resolve(promise)
or resolver.resolve(promise.yield)
(see promise.yield
) instead.when/timed
module. Use when/delay
and when/timeout
modules instead.deferred.then
.deferred.then
is deprecated and will be removed in an upcoming release. Use deferred.promise.then
instead.Object.freeze
. Promises are no longer frozen due to a horrendous v8 performance penalty. Read discussion here.
freeze()
will be reintroduced once v8 performance improves.npm test
.deferred
and deferred.resolver
no longer throw when resolved/rejected multiple times. They will return silently as if the they had succeeded. This prevents parties to whom only the resolver
has been given from using try/catch
to determine the state of the associated promise.
exports
to avoid a problem with QUnit. See #54 for more info.when.resolve(value)
creates a resolved promise for value
. See API docs.deferred.resolve
and deferred.reject
now return a promise for the fulfilled or rejected value.deferred.resolve(promise)
- when promise
resolves or rejects, so will deferred
.when()
or .then()
) return what you intend, keeping in mind that not returning something is equivalent to returning undefined
.jQuery.get()
, which seem to reject with themselves as the rejection value. See issue #41 for more information and discussion. Thanks to @KidkArolis for raising the issue.promise.otherwise(errback)
as a shortcut for promise.then(null, errback)
. See discussion here and here. Thanks to @jonnyreeves for suggesting the name "otherwise".when.any()
without a callback (#33)when.js
source (#36)when.all/any/some/map/reduce
can all now accept a promise for an array in addition to an actual array as input. This allows composing functions to do interesting things like when.reduce(when.map(...))
when.reject(promiseOrValue)
that returns a new, rejected promise.promise.always(callback)
as a shortcut for promise.then(callback, callback)
when
module that enables debug logging for promises created or consumed by when.jswhen.chain
now rejects when the input promise rejects.null
could incorrectly be used as a promise resolution value (#23)when.all
, when.some
, when.map
, or any promise that resolves to an array. (#14).then()
, when()
, and all other methods that accept callback/errback/progress handlers will throw if you pass something that's not a function. (#15)when.js
now assimilates thenables that pass the Promises/A duck-type test, but which may not be fully Promises/A compliant, such as jQuery's Deferred and curl's global API (See the API at a glance section)
when()
, and when.all/some/any/map/reduce/chain()
are all now guaranteed to return a fully Promises/A compliant promise, even when their input is not compliant.Warning: This version will not work with most AMD build tools. You should update to 0.10.4 as soon as possible.
package.json
updateswhen.map()
(thanks @smitranic), especially for large arrays where the mapFunc
is also async (i.e. returns a promise)when.all/some/any/map/reduce
handle sparse arrays (thanks @rwaldrn)when.map
and when.reduce
- just like Array.map and Array.reduce, but they operate on promises and arrays of promises