Socket
Socket
Sign inDemoInstall

vow

Package Overview
Dependencies
Maintainers
1
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vow - npm Package Compare versions

Comparing version 0.2.5 to 0.2.6

test/promise.valueof.js

3

benchmarks/node_modules/benchmark/package.json

@@ -57,3 +57,6 @@ {

"_id": "benchmark@1.0.0",
"dist": {
"shasum": "a5d861252c33cca65ab39393bd9bb63894076ac9"
},
"_from": "benchmark@"
}

6

benchmarks/node_modules/cliff/lib/cliff.js

@@ -129,3 +129,3 @@ /*

// Vow we were passed colors, then assume the first row
// If we were passed colors, then assume the first row
// is the headers for the rows

@@ -166,3 +166,3 @@ if (colors) {

// Logs the stringified table result from `rows` at the appropriate `level` using
// `cliff.logger`. Vow `colors` are supplied then use those when stringifying `rows`.
// `cliff.logger`. If `colors` are supplied then use those when stringifying `rows`.
//

@@ -182,3 +182,3 @@ cliff.putRows = function (level, rows, colors) {

// Logs the stringified table result from `objs` at the appropriate `level` using
// `cliff.logger`. Vow `colors` are supplied then use those when stringifying `objs`.
// `cliff.logger`. If `colors` are supplied then use those when stringifying `objs`.
//

@@ -185,0 +185,0 @@ cliff.putObjectRows = function (level, objs, properties, colors) {

@@ -19,3 +19,6 @@ {

"_id": "colors@0.6.0-1",
"dist": {
"shasum": "801005f3a7846d96beabd2281fde9402059830d1"
},
"_from": "colors@0.x.x"
}

@@ -45,3 +45,3 @@ //

// Vow we have a `stream` defined, use it to print a styled string,
// If we have a `stream` defined, use it to print a styled string,
// if not, we just return the stringified object.

@@ -48,0 +48,0 @@ eyes.inspect = function (obj, label, options) {

@@ -39,3 +39,6 @@ {

"_id": "eyes@0.1.8",
"dist": {
"shasum": "0689a06737156659b164f4b0921dab414d44e9ed"
},
"_from": "eyes@0.1.x"
}

@@ -20,3 +20,3 @@ /*

// Create functions on the target objects for each level
// in current.levels. Vow past is defined, remove functions
// in current.levels. If past is defined, remove functions
// for each of those levels.

@@ -23,0 +23,0 @@ //

@@ -35,3 +35,3 @@ /*

// #### @options {Object} **Optional** Options for the Logger instance
// Retreives a `winston.Logger` instance for the specified `id`. Vow
// Retreives a `winston.Logger` instance for the specified `id`. If
// an instance does not exist, one is created.

@@ -84,3 +84,3 @@ //

// Closes a `Logger` instance with the specified `id` if it exists.
// Vow no `id` is supplied then all Loggers are closed.
// If no `id` is supplied then all Loggers are closed.
//

@@ -87,0 +87,0 @@ Container.prototype.close = function (id) {

@@ -142,3 +142,3 @@ /*

// Vow we should pad for levels, do so
// If we should pad for levels, do so
if (this.padLevels) {

@@ -269,3 +269,3 @@ msg = new Array(this.levelLength - level.length + 1).join(' ') + msg;

//
// Vow an explicit transport is being queried then
// If an explicit transport is being queried then
// respond with the results from only that transport

@@ -454,3 +454,3 @@ //

//
// Vow this transport has `handleExceptions` set to `true`
// If this transport has `handleExceptions` set to `true`
// and we are not already handling exceptions, do so.

@@ -457,0 +457,0 @@ //

@@ -31,3 +31,3 @@ /*

//
function throwVow (target /*, illegal... */) {
function throwIf (target /*, illegal... */) {
Array.prototype.slice.call(arguments, 1).forEach(function (name) {

@@ -41,3 +41,3 @@ if (options[name]) {

if (options.filename || options.dirname) {
throwVow('filename or dirname', 'stream');
throwIf('filename or dirname', 'stream');
this._basename = this.filename = path.basename(options.filename) || 'winston.log';

@@ -48,3 +48,3 @@ this.dirname = options.dirname || path.dirname(options.filename);

else if (options.stream) {
throwVow('stream', 'filename', 'maxsize');
throwIf('stream', 'filename', 'maxsize');
this._stream = options.stream;

@@ -125,3 +125,3 @@

//
// Vow there is no `filename` on this instance then it was configured
// If there is no `filename` on this instance then it was configured
// with a raw `WriteableStream` instance and we should not perform any

@@ -137,3 +137,3 @@ // size restrictions.

//
// Vow there was an error enqueue the message
// If there was an error enqueue the message
//

@@ -156,3 +156,3 @@ return self._buffer.push([output, callback]);

File.prototype._write = function(data, callback) {
// Vow this is a file write stream, we could use the builtin
// If this is a file write stream, we could use the builtin
// callback functionality, however, the stream is not guaranteed

@@ -377,3 +377,3 @@ // to be an fs.WriteStream.

//
// Vow we are already attempting to open the next
// If we are already attempting to open the next
// available file then respond with a value indicating

@@ -386,3 +386,3 @@ // that the message should be buffered.

//
// Vow we dont have a stream or have exceeded our size, then create
// If we dont have a stream or have exceeded our size, then create
// the next stream and respond with a value indicating that

@@ -520,3 +520,3 @@ // the message should be buffered.

//
// Vow `stats.size` is greater than the `maxsize` for
// If `stats.size` is greater than the `maxsize` for
// this instance then try again

@@ -523,0 +523,0 @@ //

@@ -30,3 +30,6 @@ {

"_id": "async@0.1.22",
"dist": {
"shasum": "8af44c79a4e6f19f96454e02c8b2b4bd10941ed8"
},
"_from": "async@0.1.x"
}

@@ -50,4 +50,4 @@ // cycle.js

// Vow the value is an object or array, look to see if we have already
// encountered it. Vow so, return a $ref/path object. This is a hard way,
// If the value is an object or array, look to see if we have already
// encountered it. If so, return a $ref/path object. This is a hard way,
// linear search that will get slower as the number of unique objects grows.

@@ -66,3 +66,3 @@

// Vow it is an array, replicate the array.
// If it is an array, replicate the array.

@@ -76,3 +76,3 @@ if (Object.prototype.toString.apply(value) === '[object Array]') {

// Vow it is an object, replicate the object.
// If it is an object, replicate the object.

@@ -79,0 +79,0 @@ nu = {};

@@ -28,3 +28,6 @@ {

"readme": "ERROR: No README.md file found!",
"_from": "cycle@1.0.x"
"_from": "cycle@1.0.x",
"dist": {
"shasum": "3e25ac6d54dec420987b16e7c3498492171e48f7"
}
}

@@ -37,3 +37,3 @@ /*

//
// Vow the options passed in is an Array assume that
// If the options passed in is an Array assume that
// it is the Array of properties to expose from the

@@ -60,3 +60,3 @@ // on the package.json file on the parent module.

//
// Vow additional string arguments have been passed in
// If additional string arguments have been passed in
// then add them to the properties to expose on the

@@ -63,0 +63,0 @@ // parent module.

@@ -31,3 +31,6 @@ {

"_id": "pkginfo@0.2.3",
"dist": {
"shasum": "966ff036c311efed75e3059497e1e56d0055f1b1"
},
"_from": "pkginfo@0.2.x"
}

@@ -11,3 +11,3 @@ var crypto = require('crypto')

//
// The Signature element is the RFC 2104HMAC-SHA1 of selected elements from the request, and so theSignature part of the Authorization header will vary from request to request. Vow the request signature calculated by the system matches theSignature included with the request, then the requester will have demonstrated possession to the AWSSecret Access Key. The request will then be processed under the identity, and with the authority, of the developer to whom the key was issued.
// The Signature element is the RFC 2104HMAC-SHA1 of selected elements from the request, and so theSignature part of the Authorization header will vary from request to request. If the request signature calculated by the system matches theSignature included with the request, then the requester will have demonstrated possession to the AWSSecret Access Key. The request will then be processed under the identity, and with the authority, of the developer to whom the key was issued.
//

@@ -87,3 +87,3 @@ // Following is pseudo-grammar that illustrates the construction of the Authorization request header (\nmeans the Unicode code point U+000A commonly called newline).

//
// Vow the request specifies a bucket using the HTTP Host header (virtual hosted-style), append the bucket name preceded by a "/" (e.g., "/bucketname"). For path-style requests and requests that don't address a bucket, do nothing. For more information on virtual hosted-style requests, see Virtual Hosting of Buckets.
// If the request specifies a bucket using the HTTP Host header (virtual hosted-style), append the bucket name preceded by a "/" (e.g., "/bucketname"). For path-style requests and requests that don't address a bucket, do nothing. For more information on virtual hosted-style requests, see Virtual Hosting of Buckets.
//

@@ -98,7 +98,7 @@ // 3

//
// Vow the request addresses a sub-resource, like ?versioning, ?location, ?acl, ?torrent, ?lifecycle, or ?versionid append the sub-resource, its value if it has one, and the question mark. Note that in case of multiple sub-resources, sub-resources must be lexicographically sorted by sub-resource name and separated by '&'. e.g. ?acl&versionId=value.
// If the request addresses a sub-resource, like ?versioning, ?location, ?acl, ?torrent, ?lifecycle, or ?versionid append the sub-resource, its value if it has one, and the question mark. Note that in case of multiple sub-resources, sub-resources must be lexicographically sorted by sub-resource name and separated by '&'. e.g. ?acl&versionId=value.
//
// The list of sub-resources that must be included when constructing the CanonicalizedResource Element are: acl, lifecycle, location, logging, notification, partNumber, policy, requestPayment, torrent, uploadId, uploads, versionId, versioning, versions and website.
//
// Vow the request specifies query string parameters overriding the response header values (see Get Object), append the query string parameters, and its values. When signing you do not encode these values. However, when making the request, you must encode these parameter values. The query string parameters in a GET request include response-content-type, response-content-language, response-expires, response-cache-control, response-content-disposition, response-content-encoding.
// If the request specifies query string parameters overriding the response header values (see Get Object), append the query string parameters, and its values. When signing you do not encode these values. However, when making the request, you must encode these parameter values. The query string parameters in a GET request include response-content-type, response-content-language, response-expires, response-cache-control, response-content-disposition, response-content-encoding.
//

@@ -126,7 +126,7 @@ // The delete query string parameter must be including when creating the CanonicalizedResource for a Multi-Object Delete request.

//
// Vow a positional header called for in the definition of StringToSign is not present in your request, (Content-Type or Content-MD5, for example, are optional for PUT requests, and meaningless for GET requests), substitute the empty string ("") in for that position.
// If a positional header called for in the definition of StringToSign is not present in your request, (Content-Type or Content-MD5, for example, are optional for PUT requests, and meaningless for GET requests), substitute the empty string ("") in for that position.
// Time Stamp Requirement
//
// A valid time stamp (using either the HTTP Date header or an x-amz-date alternative) is mandatory for authenticated requests. Furthermore, the client time-stamp included with an authenticated request must be within 15 minutes of the Amazon S3 system time when the request is received. Vow not, the request will fail with the RequestTimeTooSkewed error status code. The intention of these restrictions is to limit the possibility that intercepted requests could be replayed by an adversary. For stronger protection against eavesdropping, use the HTTPS transport for authenticated requests.
// A valid time stamp (using either the HTTP Date header or an x-amz-date alternative) is mandatory for authenticated requests. Furthermore, the client time-stamp included with an authenticated request must be within 15 minutes of the Amazon S3 system time when the request is received. If not, the request will fail with the RequestTimeTooSkewed error status code. The intention of these restrictions is to limit the possibility that intercepted requests could be replayed by an adversary. For stronger protection against eavesdropping, use the HTTPS transport for authenticated requests.
//
// Some HTTP client libraries do not expose the ability to set the Date header for a request. Vow you have trouble including the value of the 'Date' header in the canonicalized headers, you can set the time-stamp for the request using an 'x-amz-date' header instead. The value of the x-amz-date header must be in one of the RFC 2616 formats (http://www.ietf.org/rfc/rfc2616.txt). When an x-amz-date header is present in a request, the system will ignore any Date header when computing the request signature. Therefore, if you include the x-amz-date header, use the empty string for the Date when constructing the StringToSign. See the next section for an example.
// Some HTTP client libraries do not expose the ability to set the Date header for a request. If you have trouble including the value of the 'Date' header in the canonicalized headers, you can set the time-stamp for the request using an 'x-amz-date' header instead. The value of the x-amz-date header must be in one of the RFC 2616 formats (http://www.ietf.org/rfc/rfc2616.txt). When an x-amz-date header is present in a request, the system will ignore any Date header when computing the request signature. Therefore, if you include the x-amz-date header, use the empty string for the Date when constructing the StringToSign. See the next section for an example.

@@ -33,3 +33,3 @@ module.exports = ForeverAgent

} else {
// Vow there are no pending requests just destroy the
// If there are no pending requests just destroy the
// socket and it will get removed from the pool. This

@@ -86,3 +86,3 @@ // gets us out of timeout issues and allows us to

if (this.requests[name] && this.requests[name].length) {
// Vow we have pending requests and a socket gets closed a new one
// If we have pending requests and a socket gets closed a new one
// needs to be created to take over in the pool for the one that closed.

@@ -89,0 +89,0 @@ this.createSocket(name, host, port).emit('free');

@@ -32,3 +32,6 @@ {

"_id": "request@2.9.203",
"dist": {
"shasum": "aa85cdabbb2af242129ea96017d75ff7900dc9b9"
},
"_from": "request@2.9.x"
}

@@ -5,3 +5,3 @@ // test that we can tunnel a https request over an http proxy

// Note: this requires that squid is installed.
// Vow the proxy fails to start, we'll just log a warning and assume success.
// If the proxy fails to start, we'll just log a warning and assume success.

@@ -8,0 +8,0 @@ var server = require('./server')

@@ -79,3 +79,3 @@ 'use strict';

// Vow we are under maxSockets create a new one.
// If we are under maxSockets create a new one.
self.createSocket({host: host, port: port, request: req}, function(socket) {

@@ -179,3 +179,3 @@ socket.on('free', onFree);

if (pending) {
// Vow we have pending requests and a socket gets closed a new one
// If we have pending requests and a socket gets closed a new one
// needs to be created to take over in the pool for the one that closed.

@@ -182,0 +182,0 @@ this.createSocket(pending, function(socket) {

@@ -27,3 +27,6 @@ {

"_id": "stack-trace@0.0.6",
"dist": {
"shasum": "9cb6aa3ccc7a7175993bb4c0bb8057132daaacab"
},
"_from": "stack-trace@0.0.x"
}

@@ -46,3 +46,6 @@ {

"_id": "winston@0.6.2",
"dist": {
"shasum": "c7b081a0b84e8f4da98c6e4c5948f13baa0ccd91"
},
"_from": "winston@0.6.x"
}

@@ -43,3 +43,6 @@ {

"_id": "cliff@0.1.8",
"dist": {
"shasum": "43bb4717084651494c96c31d1420679541c1b5d9"
},
"_from": "cliff@"
}

@@ -15,3 +15,3 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

var toString = Object.prototype.toString;
/**

@@ -62,7 +62,11 @@ * Creates a function that accepts a function that takes individual

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function'
? define
: function (factory) { typeof module != 'undefined'
? (module.exports = factory())
: (this.when_apply = factory());
}
// Boilerplate for AMD, Node, and browser global
);

@@ -19,6 +19,4 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when = require('./when');
/**

@@ -28,7 +26,6 @@ * Makes deferred cancelable, adding a cancel() method.

* @param deferred {Deferred} the {@link Deferred} to make cancelable
* @param canceler {Function} cancel handler function to execute when this deferred
* is canceled. This is guaranteed to run before all other rejection handlers.
* The canceler will NOT be executed if the deferred is rejected in the standard
* way, i.e. deferred.reject(). It ONLY executes if the deferred is canceled,
* i.e. deferred.cancel()
* @param canceler {Function} cancel handler function to execute when this deferred is canceled. This
* is guaranteed to run before all other rejection handlers. The canceler will NOT be executed if the
* deferred is rejected in the standard way, i.e. deferred.reject(). It ONLY executes if the deferred
* is canceled, i.e. deferred.cancel()
*

@@ -44,3 +41,3 @@ * @returns deferred, with an added cancel() method.

deferred.cancel = function() {
return deferred.reject(canceler(deferred));
return delegate.reject(canceler(deferred));
};

@@ -50,3 +47,3 @@

// to the delegate
deferred.promise.then(delegate.resolve, delegate.reject, delegate.notify);
deferred.promise.then(delegate.resolve, delegate.reject, delegate.progress);

@@ -65,7 +62,11 @@ // Replace deferred's promise with the delegate promise

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function'
? define
: function (deps, factory) { typeof module != 'undefined'
? (module.exports = factory(require('./when')))
: (this.when_cancelable = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -37,7 +37,6 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when, promiseId, pending, exceptionsToRethrow, own, warn, undef;
var promiseId, pending, exceptionsToRethrow, own, warn, undef;
when = require('./when');
promiseId = 0;

@@ -141,3 +140,3 @@ pending = {};

function deferDebug(/* id */) {
var d, err, status, value, origResolve, origReject, origNotify, origThen, origAlways, id;
var d, status, value, origResolve, origReject, origProgress, origThen, id;

@@ -147,16 +146,2 @@ // Delegate to create a Deferred;

// TODO: Remove in >= 2.1
// Add a noisy, failing then() to deferred to help people track
// down leftover deferred.then() calls in 2.0
try {
throw new Error('deferred.then was removed, use deferred.promise.then');
} catch (e) {
err = e;
}
d.then = function deferredThenIsDeprecated() {
throwUncatchable(err);
};
// End Remove 2.1
status = 'pending';

@@ -179,5 +164,2 @@ value = pending;

origAlways = d.promise.always;
d.promise.always = deprecated('promise.always', 'promise.ensure', origAlways, d.promise);
d.resolver = beget(d.resolver);

@@ -188,8 +170,8 @@ d.resolver.toString = function() {

origNotify = d.resolver.notify;
d.notify = d.resolver.notify = function(update) {
origProgress = d.resolver.progress;
d.progress = d.resolver.progress = function(update) {
// Notify global debug handler, if set
callGlobalHandler('progress', d, update);
return origNotify(update);
return origProgress(update);
};

@@ -225,2 +207,4 @@

d.then = deprecated('deferred.then', 'deferred.promise.then', d.promise.then, d);
// Add an id to all directly created promises. It'd be great

@@ -333,3 +317,2 @@ // to find a way to propagate this id to promise created by .then()

// Commented out until we need it, to appease JSHint
function deprecated(name, preferred, f, context) {

@@ -368,5 +351,9 @@ return function() {

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function'
? define
: function (deps, factory) { typeof module != 'undefined'
? (module.exports = factory(require('./when')))
: (this.when = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -14,8 +14,6 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when, undef;
var undef;
when = require('./when');
/**

@@ -47,11 +45,5 @@ * Creates a new promise that will resolve after a msec delay. If promise

when(promise,
function(val) {
setTimeout(function() {
deferred.resolve(val);
}, msec);
},
deferred.reject,
deferred.notify
);
setTimeout(function() {
deferred.resolve(promise);
}, msec);

@@ -62,7 +54,11 @@ return deferred.promise;

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function'
? define
: function (deps, factory) { typeof module != 'undefined'
? (module.exports = factory(require('./when')))
: (this.when_delay = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);
{
"name": "when",
"version": "2.0.0",
"version": "1.7.1",
"description": "A lightweight Promise and when() implementation, plus other async goodies.",

@@ -39,5 +39,5 @@ "keywords": [

"devDependencies": {
"curl": "https://github.com/cujojs/curl/tarball/0.7.3",
"test-support": "~0.1",
"promises-aplus-tests": "~1"
"buster": "~0.6",
"jshint": "",
"promise-tests": "*"
},

@@ -49,10 +49,14 @@ "main": "when",

"scripts": {
"test": "jshint . && buster test -e node && promises-aplus-tests test/when-adapter.js",
"ci": "npm test && sauceme",
"start": "buster static -e browser"
"test": "jshint *.js && buster test -e node && promise-tests promises-a test/when-adapter.js",
"test-all": "jshint *.js && buster test -e node && promise-tests all test/when-adapter.js",
"start": "buster server",
"test-browser": "jshint *.js && buster test -e browser"
},
"readme": "<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>\n\n[![Build Status](https://secure.travis-ci.org/cujojs/when.png)](http://travis-ci.org/cujojs/when) \n\n# when.js\n\nWhen.js is cujojs's lightweight [Promises/A+](http://promises-aplus.github.com/promises-spec) and `when()` implementation, derived from the async core of [wire.js](https://github.com/cujojs/wire), cujojs's IOC Container. It features:\n\n* A rock solid, battle-tested Promise implementation\n* Resolving, mapping, and reducing arrays of promises\n* Executing tasks in parallel and sequence\n* Transforming Node-style and other callback-based APIs into promise-based APIs\n\nIt passes the [Promises/A+ Test Suite](https://github.com/promises-aplus/promises-tests), is [very fast](https://github.com/cujojs/promise-perf-tests#test-results), is under 1.5k when compiled with Google Closure + gzip, and has no external dependencies.\n\n# What's New?\n\n### 2.0.0\n\n* Fully asynchronous resolutions.\n* [Promises/A+](http://promises-aplus.github.com/promises-spec) compliance.\n* New [`when/keys`](docs/api.md#object-keys) module with `all()` and `map()` for object keys/values.\n* New [`promise.ensure`](docs/api.md#ensure) as a better, and safer, replacement for `promise.always`. [See discussion](https://github.com/cujojs/when/issues/103) as to why `promise.always` is mistake-prone.\n\t* **DEPRECATED:** `promise.always`\n* `lift()` is now the preferred name for what was `bind()` in [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).\n\t* **DEPRECATED:** `bind()` in `when/function`, `when/node/function`, and `when/callbacks`. Use `lift()` instead.\n\n[Full Changelog](CHANGES.md)\n\n# Docs & Examples\n\n[API docs](docs/api.md#api)\n\n[More info on the wiki](https://github.com/cujojs/when/wiki)\n\n[Examples](https://github.com/cujojs/when/wiki/Examples)\n\nQuick Start\n===========\n\n### AMD\n\n1. Get it\n\t- `bower install when` or `yeoman install when`, *or*\n\t- `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`\n1. Configure your loader with a package:\n\n\t```js\n\tpackages: [\n\t\t{ name: 'when', location: 'path/to/when/', main: 'when' },\n\t\t// ... other packages ...\n\t]\n\t```\n\n1. `define(['when', ...], function(when, ...) { ... });` or `require(['when', ...], function(when, ...) { ... });`\n\n### Node\n\n1. `npm install when`\n1. `var when = require('when');`\n\n### RingoJS\n\n1. `ringo-admin install cujojs/when`\n1. `var when = require('when');`\n\n### Legacy environments\n\n1. `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`\n1. Add a transient `define` shim, and a `<script>` element for when.js\n\n\t```html\n\t<script>\n\t\twindow.define = function(factory) {\n\t\t\ttry{ delete window.define; } catch(e){ window.define = void 0; } // IE\n\t\t\twindow.when = factory();\n\t\t};\n\t</script>\n\t<script src=\"path/to/when/when.js\"></script>\n\t```\n\n1. `when` will be available as `window.when`\n\n# Running the Unit Tests\n\n## Node\n\nNote that when.js includes the [Promises/A+ Test Suite](https://github.com/promises-aplus/promise-tests). Running unit tests in Node will run both when.js's own test suite, and the Promises/A+ Test Suite.\n\n1. `npm install`\n1. `npm test`\n\n## Browsers\n\n1. `npm install`\n1. `npm start` - starts buster server & prints a url\n1. Point browsers at <buster server url>/capture, e.g. `localhost:1111/capture`\n1. `npm run-script test-browser`\n\nReferences\n----------\n\nMuch of this code was inspired by the async innards of [wire.js](https://github.com/cujojs/wire), and has been influenced by the great work in [Q](https://github.com/kriskowal/q), [Dojo's Deferred](https://github.com/dojo/dojo), and [uber.js](https://github.com/phiggins42/uber.js).\n",
"readme": "# when.js [![Build Status](https://secure.travis-ci.org/cujojs/when.png)](http://travis-ci.org/cujojs/when)\n\nWhen.js is cujojs's lightweight [CommonJS](http://wiki.commonjs.org/wiki/Promises) [Promises/A](http://wiki.commonjs.org/wiki/Promises/A) and `when()` implementation, derived from the async core of [wire.js](https://github.com/cujojs/wire), cujojs's IOC Container. It also provides several other useful Promise-related concepts, such as joining multiple promises, mapping and reducing collections of promises, timed promises, and has a robust [unit test suite](#running-the-unit-tests).\n\nIt 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.\n\n# What's New?\n\n### 1.7.1\n\n* Removed leftover internal usages of `deferred.then`.\n* [when/debug](https://github.com/cujojs/when/wiki/when-debug) allows configuring the set of \"fatal\" error types that will be rethrown to the host env.\n\n### 1.7.0\n\n* **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.\n* [promise.yield](when/blob/master/docs/api.md#yield)(promiseOrValue) convenience API for substituting a new value into a promise chain.\n* [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)\n* Doc improvements:\n\t* [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.\n\t* 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)\n\t* Several minor clarifications for various APIs\n* Internal improvements to assimilation and interoperability with other promise implementations.\n\n### 1.6.1\n\n* Fix for accidental coercion of non-promises. See [#62](https://github.com/cujojs/when/issues/60).\n\n### 1.6.0\n\n* New [when.join](when/blob/master/docs/api.md#whenjoin) - Joins 2 or more promises together into a single promise.\n* [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).\n* *Experimental* progress event propagation. Progress events will propagate through promise chains. [Read the details here](when/blob/master/docs/api.md#progress-events).\n* *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).\n\t* **IMPORTANT:** Continue to treat promises as if they are frozen, since `freeze()` will be reintroduced once v8 performance improves.\n* [when/debug](https://github.com/cujojs/when/wiki/when-debug) now allows setting global a debugging callback for rejected promises.\n\n[Full Changelog](https://github.com/cujojs/when/wiki/Changelog)\n\n# Docs & Examples\n\n[API docs](when/blob/master/docs/api.md#api)\n\n[More info on the wiki](https://github.com/cujojs/when/wiki)\n\n[Examples](https://github.com/cujojs/when/wiki/Examples)\n\nQuick Start\n===========\n\n### AMD\n\n1. `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`\n1. Configure your loader with a package:\n\n\t```javascript\n\tpackages: [\n\t\t{ name: 'when', location: 'path/to/when/', main: 'when' },\n\t\t// ... other packages ...\n\t]\n\t```\n\n1. `define(['when', ...], function(when, ...) { ... });` or `require(['when', ...], function(when, ...) { ... });`\n\n### Script Tag\n\n1. `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`\n1. `<script src=\"path/to/when/when.js\"></script>`\n1. `when` will be available as `window.when`\n\n### Node\n\n1. `npm install when`\n1. `var when = require('when');`\n\n### RingoJS\n\n1. `ringo-admin install cujojs/when`\n1. `var when = require('when');`\n\n# Running the Unit Tests\n\n## Node\n\nNote that when.js includes @domenic's [Promises/A Test Suite](https://github.com/domenic/promise-tests). Running unit tests in Node will run both when.js's own test suite, and the Promises/A Test Suite.\n\n1. `npm install`\n1. `npm test`\n\n## Browsers\n\n1. `npm install`\n1. `npm start` - starts buster server & prints a url\n1. Point browsers at <buster server url>/capture, e.g. `localhost:1111/capture`\n1. `npm run-script test-browser`\n\nReferences\n----------\n\nMuch of this code was inspired by @[unscriptable](https://github.com/unscriptable)'s [tiny promises](https://github.com/unscriptable/promises), the async innards of [wire.js](https://github.com/cujojs/wire), and some gists [here](https://gist.github.com/870729), [here](https://gist.github.com/892345), [here](https://gist.github.com/894356), and [here](https://gist.github.com/894360)\n\nSome of the code has been influenced by the great work in [Q](https://github.com/kriskowal/q), [Dojo's Deferred](https://github.com/dojo/dojo), and [uber.js](https://github.com/phiggins42/uber.js).\n",
"readmeFilename": "README.md",
"_id": "when@2.0.0",
"_from": "when@2.0.0"
"_id": "when@1.7.1",
"dist": {
"shasum": "cb35e2daaadffdb28d7b162faad4d861686ebc35"
},
"_from": "when@1.7.1"
}

@@ -13,8 +13,4 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when;
when = require('./when');
/**

@@ -36,7 +32,11 @@ * Run array of tasks in parallel

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function' && define.amd
? define
: function (deps, factory) { typeof exports == 'object'
? (module.exports = factory(require('./when')))
: (this.when_parallel = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -14,8 +14,4 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when;
when = require('./when');
/**

@@ -40,3 +36,3 @@ * Run array of tasks in a pipeline where the next

};
return task.apply(null, args);

@@ -54,7 +50,11 @@ };

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function' && define.amd
? define
: function (deps, factory) { typeof exports == 'object'
? (module.exports = factory(require('./when')))
: (this.when_pipeline = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -1,33 +0,43 @@

<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>
# when.js [![Build Status](https://secure.travis-ci.org/cujojs/when.png)](http://travis-ci.org/cujojs/when)
[![Build Status](https://secure.travis-ci.org/cujojs/when.png)](http://travis-ci.org/cujojs/when)
When.js is cujojs's lightweight [CommonJS](http://wiki.commonjs.org/wiki/Promises) [Promises/A](http://wiki.commonjs.org/wiki/Promises/A) and `when()` implementation, derived from the async core of [wire.js](https://github.com/cujojs/wire), cujojs's IOC Container. It also provides several other useful Promise-related concepts, such as joining multiple promises, mapping and reducing collections of promises, timed promises, and has a robust [unit test suite](#running-the-unit-tests).
# when.js
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.
When.js is cujojs's lightweight [Promises/A+](http://promises-aplus.github.com/promises-spec) and `when()` implementation, derived from the async core of [wire.js](https://github.com/cujojs/wire), cujojs's IOC Container. It features:
# What's New?
* A rock solid, battle-tested Promise implementation
* Resolving, mapping, and reducing arrays of promises
* Executing tasks in parallel and sequence
* Transforming Node-style and other callback-based APIs into promise-based APIs
### 1.7.1
It passes the [Promises/A+ Test Suite](https://github.com/promises-aplus/promises-tests), is [very fast](https://github.com/cujojs/promise-perf-tests#test-results), is under 1.5k when compiled with Google Closure + gzip, and has no external dependencies.
* Removed leftover internal usages of `deferred.then`.
* [when/debug](https://github.com/cujojs/when/wiki/when-debug) allows configuring the set of "fatal" error types that will be rethrown to the host env.
# What's New?
### 1.7.0
### 2.0.0
* **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)
* 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)
* Several minor clarifications for various APIs
* Internal improvements to assimilation and interoperability with other promise implementations.
* Fully asynchronous resolutions.
* [Promises/A+](http://promises-aplus.github.com/promises-spec) compliance.
* New [`when/keys`](docs/api.md#object-keys) module with `all()` and `map()` for object keys/values.
* New [`promise.ensure`](docs/api.md#ensure) as a better, and safer, replacement for `promise.always`. [See discussion](https://github.com/cujojs/when/issues/103) as to why `promise.always` is mistake-prone.
* **DEPRECATED:** `promise.always`
* `lift()` is now the preferred name for what was `bind()` in [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).
* **DEPRECATED:** `bind()` in `when/function`, `when/node/function`, and `when/callbacks`. Use `lift()` instead.
### 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](docs/api.md#api)
[API docs](when/blob/master/docs/api.md#api)

@@ -43,8 +53,6 @@ [More info on the wiki](https://github.com/cujojs/when/wiki)

1. Get it
- `bower install when` or `yeoman install when`, *or*
- `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`
1. `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`
1. Configure your loader with a package:
```js
```javascript
packages: [

@@ -58,2 +66,8 @@ { name: 'when', location: 'path/to/when/', main: 'when' },

### Script Tag
1. `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`
1. `<script src="path/to/when/when.js"></script>`
1. `when` will be available as `window.when`
### Node

@@ -69,19 +83,2 @@

### Legacy environments
1. `git clone https://github.com/cujojs/when` or `git submodule add https://github.com/cujojs/when`
1. Add a transient `define` shim, and a `<script>` element for when.js
```html
<script>
window.define = function(factory) {
try{ delete window.define; } catch(e){ window.define = void 0; } // IE
window.when = factory();
};
</script>
<script src="path/to/when/when.js"></script>
```
1. `when` will be available as `window.when`
# Running the Unit Tests

@@ -91,3 +88,3 @@

Note that when.js includes the [Promises/A+ Test Suite](https://github.com/promises-aplus/promise-tests). Running unit tests in Node will run both when.js's own test suite, and the Promises/A+ Test Suite.
Note that when.js includes @domenic's [Promises/A Test Suite](https://github.com/domenic/promise-tests). Running unit tests in Node will run both when.js's own test suite, and the Promises/A Test Suite.

@@ -107,2 +104,4 @@ 1. `npm install`

Much of this code was inspired by the async innards of [wire.js](https://github.com/cujojs/wire), and has been influenced by the great work in [Q](https://github.com/kriskowal/q), [Dojo's Deferred](https://github.com/dojo/dojo), and [uber.js](https://github.com/phiggins42/uber.js).
Much of this code was inspired by @[unscriptable](https://github.com/unscriptable)'s [tiny promises](https://github.com/unscriptable/promises), the async innards of [wire.js](https://github.com/cujojs/wire), and some gists [here](https://gist.github.com/870729), [here](https://gist.github.com/892345), [here](https://gist.github.com/894356), and [here](https://gist.github.com/894360)
Some of the code has been influenced by the great work in [Q](https://github.com/kriskowal/q), [Dojo's Deferred](https://github.com/dojo/dojo), and [uber.js](https://github.com/phiggins42/uber.js).

@@ -13,8 +13,4 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when;
when = require('./when');
/**

@@ -39,7 +35,11 @@ * Run array of tasks in sequence with no overlap

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function' && define.amd
? define
: function (deps, factory) { typeof exports == 'object'
? (module.exports = factory(require('./when')))
: (this.when_sequence = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -14,9 +14,4 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./timeout', './delay'], function(timeout, delay) {
var timeout, delay;
timeout = require('./timeout');
delay = require('./delay');
return {

@@ -28,7 +23,11 @@ timeout: timeout,

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function'
? define
: function (deps, factory) { typeof module != 'undefined'
? (module.exports = factory.apply(this, deps.map(require)))
: (this.when_timed = factory(this.when_timeout, this.when_delay));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -15,8 +15,6 @@ /** @license MIT License (c) copyright B Cavalier & J Hann */

(function(define) {
define(function(require) {
define(['./when'], function(when) {
var when, undef;
var undef;
when = require('./when');
/**

@@ -62,4 +60,3 @@ * Returns a new promise that will automatically reject after msec if

deferred.reject(reason);
},
deferred.notify
}
);

@@ -71,7 +68,11 @@

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(require); }
// Boilerplate for AMD and Node
})(typeof define == 'function'
? define
: function (deps, factory) { typeof module != 'undefined'
? (module.exports = factory(require('./when')))
: (this.when_timeout = factory(this.when));
}
// Boilerplate for AMD, Node, and browser global
);

@@ -1,2 +0,2 @@

/** @license MIT License (c) copyright 2011-2013 original author or authors */
/** @license MIT License (c) copyright B Cavalier & J Hann */

@@ -10,26 +10,30 @@ /**

*
* @author Brian Cavalier
* @author John Hann
* @version 2.0.0
* @version 1.7.1
*/
(function(define) { 'use strict';
define(function () {
var reduceArray, slice, undef;
//
// Public API
//
when.defer = defer; // Create a deferred
when.resolve = resolve; // Create a resolved promise
when.reject = reject; // Create a rejected promise
when.defer = defer; // Create a deferred
when.resolve = resolve; // Create a resolved promise
when.reject = reject; // Create a rejected promise
when.join = join; // Join 2 or more promises
when.join = join; // Join 2 or more promises
when.all = all; // Resolve a list of promises
when.map = map; // Array.map() for promises
when.reduce = reduce; // Array.reduce() for promises
when.all = all; // Resolve a list of promises
when.map = map; // Array.map() for promises
when.reduce = reduce; // Array.reduce() for promises
when.any = any; // One-winner race
when.some = some; // Multi-winner race
when.any = any; // One-winner race
when.some = some; // Multi-winner race
when.isPromise = isPromise; // Determine if a thing is a promise
when.chain = chain; // Make a promise trigger another resolver
when.isPromise = isPromise; // Determine if a thing is a promise
/**

@@ -57,2 +61,61 @@ * Register an observer for a promise or immediate value.

/**
* Returns promiseOrValue if promiseOrValue is a {@link Promise}, a new Promise if
* promiseOrValue is a foreign promise, or a new, already-fulfilled {@link Promise}
* whose value is promiseOrValue if promiseOrValue is an immediate value.
*
* @param {*} promiseOrValue
* @returns Guaranteed to return a trusted Promise. If promiseOrValue is a when.js {@link Promise}
* returns promiseOrValue, otherwise, returns a new, already-resolved, when.js {@link Promise}
* whose resolution value is:
* * the resolution value of promiseOrValue if it's a foreign promise, or
* * promiseOrValue if it's a value
*/
function resolve(promiseOrValue) {
var promise, deferred;
if(promiseOrValue instanceof Promise) {
// It's a when.js promise, so we trust it
promise = promiseOrValue;
} else {
// It's not a when.js promise. See if it's a foreign promise or a value.
if(isPromise(promiseOrValue)) {
// It's a thenable, but we don't know where it came from, so don't trust
// its implementation entirely. Introduce a trusted middleman when.js promise
deferred = defer();
// IMPORTANT: This is the only place when.js should ever call .then() on an
// untrusted promise. Don't expose the return value to the untrusted promise
promiseOrValue.then(
function(value) { deferred.resolve(value); },
function(reason) { deferred.reject(reason); },
function(update) { deferred.progress(update); }
);
promise = deferred.promise;
} else {
// It's a value, not a promise. Create a resolved promise for it.
promise = fulfilled(promiseOrValue);
}
}
return promise;
}
/**
* Returns a rejected promise for the supplied promiseOrValue. The returned
* promise will be rejected with:
* - promiseOrValue, if it is a value, or
* - if promiseOrValue is a promise
* - promiseOrValue's value after it is fulfilled
* - promiseOrValue's reason after it is rejected
* @param {*} promiseOrValue the rejected value of the returned {@link Promise}
* @return {Promise} rejected {@link Promise}
*/
function reject(promiseOrValue) {
return when(promiseOrValue, rejected);
}
/**
* Trusted Promise constructor. A Promise created from this constructor is

@@ -70,2 +133,14 @@ * a trusted when.js promise. Any other duck-typed promise is considered

/**
* Register a callback that will be called when a promise is
* fulfilled or rejected. Optionally also register a progress handler.
* Shortcut for .then(onFulfilledOrRejected, onFulfilledOrRejected, onProgress)
* @param {function?} [onFulfilledOrRejected]
* @param {function?} [onProgress]
* @return {Promise}
*/
always: function(onFulfilledOrRejected, onProgress) {
return this.then(onFulfilledOrRejected, onFulfilledOrRejected, onProgress);
},
/**
* Register a rejection handler. Shortcut for .then(undefined, onRejected)

@@ -80,22 +155,2 @@ * @param {function?} onRejected

/**
* Ensures that onFulfilledOrRejected will be called regardless of whether
* this promise is fulfilled or rejected. onFulfilledOrRejected WILL NOT
* receive the promises' value or reason. Any returned value will be disregarded.
* onFulfilledOrRejected may throw or return a rejected promise to signal
* an additional error.
* @param {function} onFulfilledOrRejected handler to be called regardless of
* fulfillment or rejection
* @returns {Promise}
*/
ensure: function(onFulfilledOrRejected) {
var self = this;
return this.then(injectHandler, injectHandler).yield(self);
function injectHandler() {
return resolve(onFulfilledOrRejected());
}
},
/**
* Shortcut for .then(function() { return value; })

@@ -108,3 +163,3 @@ * @param {*} value

*/
'yield': function(value) {
yield: function(value) {
return this.then(function() {

@@ -118,3 +173,3 @@ return value;

* for the onFulfilled to be called with the array as its argument list
* i.e. onFulfilled.apply(undefined, array).
* i.e. onFulfilled.spread(undefined, array).
* @param {function} onFulfilled function to receive spread arguments

@@ -130,10 +185,2 @@ * @return {Promise}

});
},
/**
* Shortcut for .then(onFulfilledOrRejected, onFulfilledOrRejected)
* @deprecated
*/
always: function(onFulfilledOrRejected, onProgress) {
return this.then(onFulfilledOrRejected, onFulfilledOrRejected, onProgress);
}

@@ -143,275 +190,197 @@ };

/**
* Returns a resolved promise. The returned promise will be
* - fulfilled with promiseOrValue if it is a value, or
* - if promiseOrValue is a promise
* - fulfilled with promiseOrValue's value after it is fulfilled
* - rejected with promiseOrValue's reason after it is rejected
* @param {*} value
* @return {Promise}
* Create an already-resolved promise for the supplied value
* @private
*
* @param {*} value
* @return {Promise} fulfilled promise
*/
function resolve(value) {
return promise(function(resolve) {
resolve(value);
function fulfilled(value) {
var p = new Promise(function(onFulfilled) {
// TODO: Promises/A+ check typeof onFulfilled
try {
return resolve(onFulfilled ? onFulfilled(value) : value);
} catch(e) {
return rejected(e);
}
});
return p;
}
/**
* Returns a rejected promise for the supplied promiseOrValue. The returned
* promise will be rejected with:
* - promiseOrValue, if it is a value, or
* - if promiseOrValue is a promise
* - promiseOrValue's value after it is fulfilled
* - promiseOrValue's reason after it is rejected
* @param {*} promiseOrValue the rejected value of the returned {@link Promise}
* @return {Promise} rejected {@link Promise}
* Create an already-rejected {@link Promise} with the supplied
* rejection reason.
* @private
*
* @param {*} reason
* @return {Promise} rejected promise
*/
function reject(promiseOrValue) {
return when(promiseOrValue, rejected);
function rejected(reason) {
var p = new Promise(function(_, onRejected) {
// TODO: Promises/A+ check typeof onRejected
try {
return onRejected ? resolve(onRejected(reason)) : rejected(reason);
} catch(e) {
return rejected(e);
}
});
return p;
}
/**
* Creates a new Deferred with fully isolated resolver and promise parts,
* Creates a new, Deferred with fully isolated resolver and promise parts,
* either or both of which may be given out safely to consumers.
* The resolver has resolve, reject, and progress. The promise
* The Deferred itself has the full API: resolve, reject, progress, and
* then. The resolver has resolve, reject, and progress. The promise
* only has then.
*
* @return {{
* promise: Promise,
* resolver: {
* resolve: function:Promise,
* reject: function:Promise,
* notify: function:Promise
* }}}
* @return {Deferred}
*/
function defer() {
var deferred, pending, resolved;
var deferred, promise, handlers, progressHandlers,
_then, _progress, _resolve;
// Optimize object shape
/**
* The promise for the new deferred
* @type {Promise}
*/
promise = new Promise(then);
/**
* The full Deferred object, with {@link Promise} and {@link Resolver} parts
* @class Deferred
* @name Deferred
*/
deferred = {
promise: undef, resolve: undef, reject: undef, notify: undef,
resolver: { resolve: undef, reject: undef, notify: undef }
then: then, // DEPRECATED: use deferred.promise.then
resolve: promiseResolve,
reject: promiseReject,
// TODO: Consider renaming progress() to notify()
progress: promiseProgress,
promise: promise,
resolver: {
resolve: promiseResolve,
reject: promiseReject,
progress: promiseProgress
}
};
deferred.promise = pending = promise(makeDeferred);
handlers = [];
progressHandlers = [];
return deferred;
/**
* Pre-resolution then() that adds the supplied callback, errback, and progback
* functions to the registered listeners
* @private
*
* @param {function?} [onFulfilled] resolution handler
* @param {function?} [onRejected] rejection handler
* @param {function?} [onProgress] progress handler
*/
_then = function(onFulfilled, onRejected, onProgress) {
// TODO: Promises/A+ check typeof onFulfilled, onRejected, onProgress
var deferred, progressHandler;
function makeDeferred(resolvePending, rejectPending, notifyPending) {
deferred.resolve = deferred.resolver.resolve = function(value) {
if(resolved) {
return resolve(value);
}
resolved = true;
resolvePending(value);
return pending;
};
deferred = defer();
deferred.reject = deferred.resolver.reject = function(reason) {
if(resolved) {
return resolve(rejected(reason));
progressHandler = typeof onProgress === 'function'
? function(update) {
try {
// Allow progress handler to transform progress event
deferred.progress(onProgress(update));
} catch(e) {
// Use caught value as progress
deferred.progress(e);
}
}
resolved = true;
rejectPending(reason);
return pending;
};
: function(update) { deferred.progress(update); };
deferred.notify = deferred.resolver.notify = function(update) {
notifyPending(update);
return update;
};
}
}
handlers.push(function(promise) {
promise.then(onFulfilled, onRejected)
.then(deferred.resolve, deferred.reject, progressHandler);
});
/**
* Creates a new promise whose fate is determined by resolver.
* @private (for now)
* @param {function} resolver function(resolve, reject, notify)
* @returns {Promise} promise whose fate is determine by resolver
*/
function promise(resolver) {
var value, handlers = [];
progressHandlers.push(progressHandler);
// Call the provider resolver to seal the promise's fate
try {
resolver(promiseResolve, promiseReject, promiseNotify);
} catch(e) {
promiseReject(e);
}
return deferred.promise;
};
// Return the promise
return new Promise(then);
/**
* Register handlers for this promise.
* @param [onFulfilled] {Function} fulfillment handler
* @param [onRejected] {Function} rejection handler
* @param [onProgress] {Function} progress handler
* @return {Promise} new Promise
* Issue a progress event, notifying all progress listeners
* @private
* @param {*} update progress event payload to pass to all listeners
*/
function then(onFulfilled, onRejected, onProgress) {
return promise(function(resolve, reject, notify) {
handlers
// Call handlers later, after resolution
? handlers.push(function(value) {
value.then(onFulfilled, onRejected, onProgress)
.then(resolve, reject, notify);
})
// Call handlers soon, but not in the current stack
: enqueue(function() {
value.then(onFulfilled, onRejected, onProgress)
.then(resolve, reject, notify);
});
});
}
_progress = function(update) {
processQueue(progressHandlers, update);
return update;
};
/**
* Transition from pre-resolution state to post-resolution state, notifying
* all listeners of the ultimate fulfillment or rejection
* @param {*|Promise} val resolution value
* all listeners of the resolution or rejection
* @private
* @param {*} value the value of this deferred
*/
function promiseResolve(val) {
if(!handlers) {
return;
}
_resolve = function(value) {
value = resolve(value);
value = coerce(val);
scheduleHandlers(handlers, value);
// Replace _then with one that directly notifies with the result.
_then = value.then;
// Replace _resolve so that this Deferred can only be resolved once
_resolve = resolve;
// Make _progress a noop, to disallow progress for the resolved promise.
_progress = noop;
handlers = undef;
// Notify handlers
processQueue(handlers, value);
// Free progressHandlers array since we'll never issue progress events
progressHandlers = handlers = undef;
return value;
};
return deferred;
/**
* Wrapper to allow _then to be replaced safely
* @param {function?} [onFulfilled] resolution handler
* @param {function?} [onRejected] rejection handler
* @param {function?} [onProgress] progress handler
* @return {Promise} new promise
*/
function then(onFulfilled, onRejected, onProgress) {
// TODO: Promises/A+ check typeof onFulfilled, onRejected, onProgress
return _then(onFulfilled, onRejected, onProgress);
}
/**
* Reject this promise with the supplied reason, which will be used verbatim.
* @param {*} reason reason for the rejection
* Wrapper to allow _resolve to be replaced
*/
function promiseReject(reason) {
promiseResolve(rejected(reason));
function promiseResolve(val) {
return _resolve(val);
}
/**
* Issue a progress event, notifying all progress listeners
* @param {*} update progress event payload to pass to all listeners
* Wrapper to allow _reject to be replaced
*/
function promiseNotify(update) {
if(handlers) {
scheduleHandlers(handlers, progressing(update));
}
function promiseReject(err) {
return _resolve(rejected(err));
}
}
/**
* Coerces x to a trusted Promise
*
* @private
* @param {*} x thing to coerce
* @returns {Promise} Guaranteed to return a trusted Promise. If x
* is trusted, returns x, otherwise, returns a new, trusted, already-resolved
* Promise whose resolution value is:
* * the resolution value of x if it's a foreign promise, or
* * x if it's a value
*/
function coerce(x) {
if(x instanceof Promise) {
return x;
} else if (x !== Object(x)) {
return fulfilled(x);
/**
* Wrapper to allow _progress to be replaced
*/
function promiseProgress(update) {
return _progress(update);
}
return promise(function(resolve, reject, notify) {
enqueue(function() {
try {
// We must check and assimilate in the same tick, but not the
// current tick, careful only to access promiseOrValue.then once.
var untrustedThen = x.then;
if(typeof untrustedThen === 'function') {
fcall(untrustedThen, x, resolve, reject, notify);
} else {
// It's a value, create a fulfilled wrapper
resolve(fulfilled(x));
}
} catch(e) {
// Something went wrong, reject
reject(e);
}
});
});
}
/**
* Create an already-fulfilled promise for the supplied value
* @private
* @param {*} value
* @return {Promise} fulfilled promise
*/
function fulfilled(value) {
var self = new Promise(function (onFulfilled) {
try {
return typeof onFulfilled == 'function'
? coerce(onFulfilled(value)) : self;
} catch (e) {
return rejected(e);
}
});
return self;
}
/**
* Create an already-rejected promise with the supplied rejection reason.
* @private
* @param {*} reason
* @return {Promise} rejected promise
*/
function rejected(reason) {
var self = new Promise(function (_, onRejected) {
try {
return typeof onRejected == 'function'
? coerce(onRejected(reason)) : self;
} catch (e) {
return rejected(e);
}
});
return self;
}
/**
* Create a progress promise with the supplied update.
* @private
* @param {*} update
* @return {Promise} progress promise
*/
function progressing(update) {
var self = new Promise(function (_, __, onProgress) {
try {
return typeof onProgress == 'function'
? progressing(onProgress(update)) : self;
} catch (e) {
return progressing(e);
}
});
return self;
}
/**
* Schedule a task that will process a list of handlers
* in the next queue drain run.
* @private
* @param {Array} handlers queue of handlers to execute
* @param {*} value passed as the only arg to each handler
*/
function scheduleHandlers(handlers, value) {
enqueue(function() {
var handler, i = 0;
while (handler = handlers[i++]) {
handler(value);
}
});
}
/**
* Determines if promiseOrValue is a promise or not
* Determines if promiseOrValue is a promise or not. Uses the feature
* test from http://wiki.commonjs.org/wiki/Promises/A to determine if
* promiseOrValue is a promise.
*

@@ -438,4 +407,4 @@ * @param {*} promiseOrValue anything

* @returns {Promise} promise that will resolve to an array of howMany values that
* resolved first, or will reject with an array of
* (promisesOrValues.length - howMany) + 1 rejection reasons.
* resolved first, or will reject with an array of (promisesOrValues.length - howMany) + 1
* rejection reasons.
*/

@@ -448,52 +417,58 @@ function some(promisesOrValues, howMany, onFulfilled, onRejected, onProgress) {

return promise(resolveSome).then(onFulfilled, onRejected, onProgress);
var toResolve, toReject, values, reasons, deferred, fulfillOne, rejectOne, progress, len, i;
function resolveSome(resolve, reject, notify) {
var toResolve, toReject, values, reasons, fulfillOne, rejectOne, len, i;
len = promisesOrValues.length >>> 0;
len = promisesOrValues.length >>> 0;
toResolve = Math.max(0, Math.min(howMany, len));
values = [];
toResolve = Math.max(0, Math.min(howMany, len));
values = [];
toReject = (len - toResolve) + 1;
reasons = [];
toReject = (len - toResolve) + 1;
reasons = [];
deferred = defer();
// No items in the input, resolve immediately
if (!toResolve) {
resolve(values);
// No items in the input, resolve immediately
if (!toResolve) {
deferred.resolve(values);
} else {
rejectOne = function(reason) {
reasons.push(reason);
if(!--toReject) {
fulfillOne = rejectOne = noop;
reject(reasons);
}
};
} else {
progress = deferred.progress;
fulfillOne = function(val) {
// This orders the values based on promise resolution order
values.push(val);
if (!--toResolve) {
fulfillOne = rejectOne = noop;
resolve(values);
}
};
rejectOne = function(reason) {
reasons.push(reason);
if(!--toReject) {
fulfillOne = rejectOne = noop;
deferred.reject(reasons);
}
};
for(i = 0; i < len; ++i) {
if(i in promisesOrValues) {
when(promisesOrValues[i], fulfiller, rejecter, notify);
}
fulfillOne = function(val) {
// This orders the values based on promise resolution order
// Another strategy would be to use the original position of
// the corresponding promise.
values.push(val);
if (!--toResolve) {
fulfillOne = rejectOne = noop;
deferred.resolve(values);
}
}
};
function rejecter(reason) {
rejectOne(reason);
for(i = 0; i < len; ++i) {
if(i in promisesOrValues) {
when(promisesOrValues[i], fulfiller, rejecter, progress);
}
}
}
function fulfiller(val) {
fulfillOne(val);
}
return deferred.then(onFulfilled, onRejected, onProgress);
function rejecter(reason) {
rejectOne(reason);
}
function fulfiller(val) {
fulfillOne(val);
}
});

@@ -556,3 +531,3 @@ }

*
* @param {Array|Promise} array array of anything, may contain a mix
* @param {Array|Promise} promise array of anything, may contain a mix
* of {@link Promise}s and values

@@ -564,39 +539,39 @@ * @param {function} mapFunc mapping function mapFunc(value) which may return

*/
function map(array, mapFunc) {
return when(array, function(array) {
function map(promise, mapFunc) {
return when(promise, function(array) {
var results, len, toResolve, resolve, i, d;
return promise(resolveMap);
// Since we know the resulting length, we can preallocate the results
// array to avoid array expansions.
toResolve = len = array.length >>> 0;
results = [];
d = defer();
function resolveMap(resolve, reject, notify) {
var results, len, toResolve, resolveOne, i;
if(!toResolve) {
d.resolve(results);
} else {
// Since we know the resulting length, we can preallocate the results
// array to avoid array expansions.
toResolve = len = array.length >>> 0;
results = [];
resolve = function resolveOne(item, i) {
when(item, mapFunc).then(function(mapped) {
results[i] = mapped;
if(!toResolve) {
resolve(results);
} else {
if(!--toResolve) {
d.resolve(results);
}
}, d.reject);
};
resolveOne = function(item, i) {
when(item, mapFunc).then(function(mapped) {
results[i] = mapped;
if(!--toResolve) {
resolve(results);
}
}, reject, notify);
};
// Since mapFunc may be async, get all invocations of it into flight
for(i = 0; i < len; i++) {
if(i in array) {
resolveOne(array[i], i);
} else {
--toResolve;
}
// Since mapFunc may be async, get all invocations of it into flight
for(i = 0; i < len; i++) {
if(i in array) {
resolve(array[i], i);
} else {
--toResolve;
}
}
}
return d.promise;
});

@@ -619,3 +594,3 @@ }

function reduce(promise, reduceFunc /*, initialValue */) {
var args = fcall(slice, arguments, 1);
var args = slice.call(arguments, 1);

@@ -641,26 +616,44 @@ return when(promise, function(array) {

//
// Utilities, etc.
//
/**
* Ensure that resolution of promiseOrValue will trigger resolver with the
* value or reason of promiseOrValue, or instead with resolveValue if it is provided.
*
* @param promiseOrValue
* @param {Object} resolver
* @param {function} resolver.resolve
* @param {function} resolver.reject
* @param {*} [resolveValue]
* @returns {Promise}
*/
function chain(promiseOrValue, resolver, resolveValue) {
var useResolveValue = arguments.length > 2;
var reduceArray, slice, fcall, nextTick, handlerQueue,
timeout, funcProto, call, arrayProto, undef;
return when(promiseOrValue,
function(val) {
val = useResolveValue ? resolveValue : val;
resolver.resolve(val);
return val;
},
function(reason) {
resolver.reject(reason);
return rejected(reason);
},
resolver.progress
);
}
//
// Shared handler queue processing
// Utility functions
//
// Credit to Twisol (https://github.com/Twisol) for suggesting
// this type of extensible queue + trampoline approach for
// next-tick conflation.
handlerQueue = [];
/**
* Enqueue a task. If the queue is not currently scheduled to be
* drained, schedule it.
* @param {function} task
* Apply all functions in queue to value
* @param {Array} queue array of functions to execute
* @param {*} value argument passed to each function
*/
function enqueue(task) {
if(handlerQueue.push(task) === 1) {
scheduleDrainQueue();
function processQueue(queue, value) {
var handler, i = 0;
while (handler = queue[i++]) {
handler(value);
}

@@ -670,62 +663,49 @@ }

/**
* Schedule the queue to be drained in the next tick.
* Helper that checks arrayOfCallbacks to ensure that each element is either
* a function, or null or undefined.
* @private
* @param {number} start index at which to start checking items in arrayOfCallbacks
* @param {Array} arrayOfCallbacks array to check
* @throws {Error} if any element of arrayOfCallbacks is something other than
* a functions, null, or undefined.
*/
function scheduleDrainQueue() {
nextTick(drainQueue);
}
function checkCallbacks(start, arrayOfCallbacks) {
// TODO: Promises/A+ update type checking and docs
var arg, i = arrayOfCallbacks.length;
/**
* Drain the handler queue entirely or partially, being careful to allow
* the queue to be extended while it is being processed, and to continue
* processing until it is truly empty.
*/
function drainQueue() {
var task, i = 0;
while(i > start) {
arg = arrayOfCallbacks[--i];
while(task = handlerQueue[i++]) {
task();
if (arg != null && typeof arg != 'function') {
throw new Error('arg '+i+' must be a function');
}
}
handlerQueue = [];
}
//
// Capture function and array utils
//
/*global setImmediate:true*/
/**
* No-Op function used in method replacement
* @private
*/
function noop() {}
// capture setTimeout to avoid being caught by fake timers used in time based tests
timeout = setTimeout;
nextTick = typeof setImmediate === 'function'
? typeof window === 'undefined'
? setImmediate
: setImmediate.bind(window)
: typeof process === 'object'
? process.nextTick
: function(task) { timeout(task, 0); };
slice = [].slice;
// Safe function calls
funcProto = Function.prototype;
call = funcProto.call;
fcall = funcProto.bind
? call.bind(call)
: function(f, context) {
return f.apply(context, slice.call(arguments, 2));
};
// Safe array ops
arrayProto = [];
slice = arrayProto.slice;
// ES5 reduce implementation if native not available
// See: http://es5.github.com/#x15.4.4.21 as there are many
// specifics and edge cases. ES5 dictates that reduce.length === 1
// This implementation deviates from ES5 spec in the following ways:
// 1. It does not check if reduceFunc is a Callable
reduceArray = arrayProto.reduce ||
// specifics and edge cases.
reduceArray = [].reduce ||
function(reduceFunc /*, initialValue */) {
/*jshint maxcomplexity: 7*/
// ES5 dictates that reduce.length === 1
// This implementation deviates from ES5 spec in the following ways:
// 1. It does not check if reduceFunc is a Callable
var arr, args, reduced, len, i;
i = 0;
// This generates a jshint warning, despite being valid
// "Missing 'new' prefix when invoking a constructor."
// See https://github.com/jshint/jshint/issues/392
arr = Object(this);

@@ -758,2 +738,3 @@ len = arr.length >>> 0;

for(;i < len; ++i) {
// Skip holes
if(i in arr) {

@@ -767,30 +748,2 @@ reduced = reduceFunc(reduced, arr[i], i, arr);

//
// Utility functions
//
/**
* Helper that checks arrayOfCallbacks to ensure that each element is either
* a function, or null or undefined.
* @private
* @param {number} start index at which to start checking items in arrayOfCallbacks
* @param {Array} arrayOfCallbacks array to check
* @throws {Error} if any element of arrayOfCallbacks is something other than
* a functions, null, or undefined.
*/
function checkCallbacks(start, arrayOfCallbacks) {
// TODO: Promises/A+ update type checking and docs
var arg, i = arrayOfCallbacks.length;
while(i > start) {
arg = arrayOfCallbacks[--i];
if (arg != null && typeof arg != 'function') {
throw new Error('arg '+i+' must be a function');
}
}
}
function noop() {}
function identity(x) {

@@ -802,4 +755,9 @@ return x;

});
})(
typeof define === 'function' && define.amd ? define : function (factory) { module.exports = factory(); }
})(typeof define == 'function' && define.amd
? define
: function (factory) { typeof exports === 'object'
? (module.exports = factory())
: (this.when = factory());
}
// Boilerplate for AMD, Node, and browser global
);

@@ -9,3 +9,3 @@ /**

*
* @version 0.2.5
* @version 0.2.6
*/

@@ -94,3 +94,3 @@

cb = function() {
onResolved(_this);
return onResolved(_this);
};

@@ -364,4 +364,4 @@

delay : function(val, timeout) {
return this.promise(val).delay(timeout);
delay : function(val, timeout, fulfilledVal) {
return this.promise(val).delay(timeout, fulfilledVal);
},

@@ -368,0 +368,0 @@

{
"name" : "vow",
"version" : "0.2.5",
"version" : "0.2.6",
"description" : "Promises/A+ proposal compatible promises library",

@@ -5,0 +5,0 @@ "homepage" : "https://github.com/dfilatov/jspromise",

@@ -38,2 +38,3 @@ <a href="http://promises-aplus.github.com/promises-spec"><img src="http://promises-aplus.github.com/promises-spec/assets/logo-small.png" align="right" /></a>

* [done](#done)
* [delay](#delaydelay)
* [timeout](#timeouttimeout)

@@ -58,3 +59,4 @@ * [sync](#syncwithpromise)

* [any](#anypromisesorvalues)
* [timeout](#timeoutpromise-timeout)
* [delay](#delayvalue-delay)
* [timeout](#timeoutvalue-timeout)

@@ -169,5 +171,7 @@ ####Vow.promise([value])####

````
####delay(delay)####
Returns a new promise that to be fulfilled after a ````delay```` milliseconds if promise is fulfilled, or immediately rejected if promise is rejected.
####timeout(timeout)####
Returns a new promise that to be rejected after a ````timeout```` if promise does not resolved beforehand.
Returns a new promise that to be rejected after a ````timeout```` milliseconds if promise does not resolved beforehand.
````javascript

@@ -307,3 +311,6 @@ var promise = Vow.promise(),

####timeout(promise, timeout)####
####delay(value, delay)####
Static equivalent for [promise.delay](#delaydelay). If given ````value```` is not a promise, ````value```` is equivalent to fulfilled promise.
####timeout(value, timeout)####
Static equivalent for [promise.timeout](#timeouttimeout). If given ````value```` is not a promise, ````value```` is equivalent to fulfilled promise.

@@ -1,12 +0,25 @@

var Vow = require('./index');
var Vow = require('./lib/vow');
var promise1 = Vow.promise(),
promise2 = Vow.promise();
Vow.allResolved([promise1, promise2])
.spread(function(promise1, promise2) {
console.log(promise1.valueOf(), promise2.valueOf());
function test(promise) {
return promise.always(function(p) {
console.log(p.valueOf());
return p.valueOf();
});
}
promise1.reject('error');
promise2.fulfill('ok');
function testOk(promise) {
promise.fulfill('ok');
return test(promise);
}
function testErr(promise) {
promise.reject('not-ok');
return test(promise);
}
function promise() {
return Vow.promise();
}
testOk(promise()).then(console.log);
//testErr(promise()).then(console.log);

@@ -20,3 +20,29 @@ module.exports = {

});
},
'resulting promise should be fulfilled with returned value of onResolved callback' : function(test) {
var promise = Vow.promise();
promise.fulfill('ok');
promise
.always(function() {
return 'ok-always';
})
.then(function(val) {
test.strictEqual(val, 'ok-always');
test.done();
});
},
'resulting promise should be rejected with exception in onResolved callback' : function(test) {
var promise = Vow.promise();
promise.fulfill('ok');
promise
.always(function() {
throw 'error-always';
})
.fail(function(err) {
test.strictEqual(err, 'error-always');
test.done();
});
}
};

@@ -9,3 +9,3 @@ /**

*
* @version 0.2.5
*/(function(e){var t=function(e){this._res=e,this._isFulfilled=!!arguments.length,this._isRejected=!1,this._fulfilledCallbacks=[],this._rejectedCallbacks=[]};t.prototype={valueOf:function(){return this._res},isFulfilled:function(){return this._isFulfilled},isRejected:function(){return this._isRejected},isResolved:function(){return this._isFulfilled||this._isRejected},fulfill:function(e){if(this.isResolved())return;this._isFulfilled=!0,this._res=e,this._callCallbacks(this._fulfilledCallbacks),this._fulfilledCallbacks=this._rejectedCallbacks=r},reject:function(e){if(this.isResolved())return;this._isRejected=!0,this._res=e,this._callCallbacks(this._rejectedCallbacks),this._fulfilledCallbacks=this._rejectedCallbacks=r},then:function(e,n){var r=new t,i;return this._isRejected||(i={promise:r,fn:e},this._isFulfilled?this._callCallbacks([i]):this._fulfilledCallbacks.push(i)),this._isFulfilled||(i={promise:r,fn:n},this._isRejected?this._callCallbacks([i]):this._rejectedCallbacks.push(i)),r},fail:function(e){return this.then(r,e)},always:function(e){var t=this,n=function(){e(t)};return this.then(n,n)},spread:function(e,t){return this.then(function(t){return e.apply(this,t)},t)},done:function(){this.fail(s)},delay:function(e){return this.then(function(n){var r=new t;return setTimeout(function(){r.fulfill(n)},e),r})},timeout:function(e){var n=new t,r=setTimeout(function(){n.reject(Error("timed out"))},e);return n.sync(this),n.always(function(){clearTimeout(r)}),n},sync:function(e){var t=this;e.then(function(e){t.fulfill(e)},function(e){t.reject(e)})},_callCallbacks:function(e){var t=e.length;if(!t)return;var r=this._res,s=this.isFulfilled();i(function(){var i=0,u,a,f;while(i<t){u=e[i++],a=u.promise,f=u.fn;if(o(f)){var l;try{l=f(r)}catch(c){a.reject(c);continue}n.isPromise(l)?function(e){l.then(function(t){e.fulfill(t)},function(t){e.reject(t)})}(a):a.fulfill(l)}else s?a.fulfill(r):a.reject(r)}})}};var n={promise:function(e){return arguments.length?this.isPromise(e)?e:new t(e):new t},when:function(e,t,n){return this.promise(e).then(t,n)},fail:function(e,t){return this.when(e,r,t)},always:function(e,t){return this.promise(e).always(t)},spread:function(e,t,n){return this.promise(e).spread(t,n)},done:function(e){this.isPromise(e)&&e.done()},isPromise:function(e){return e&&o(e.then)},valueOf:function(e){return this.isPromise(e)?e.valueOf():e},isFulfilled:function(e){return this.isPromise(e)?e.isFulfilled():!0},isRejected:function(e){return this.isPromise(e)?e.isRejected():!1},isResolved:function(e){return this.isPromise(e)?e.isResolved():!0},fulfill:function(e){return this.when(e,r,function(e){return e})},reject:function(e){return this.when(e,function(e){var n=new t;return n.reject(e),n})},resolve:function(e){return this.isPromise(e)?e:this.when(e)},invoke:function(e){try{return this.promise(e.apply(null,u.call(arguments,1)))}catch(t){return this.reject(t)}},forEach:function(e,t,n,r){var i=r?r.length:e.length,s=0;while(s<i)this.when(e[r?r[s]:s],t,n),++s},all:function(e){var r=new t,i=f(e),s=i?l(e):c(e),o=s.length,u=i?[]:{};if(!o)return r.fulfill(u),r;var a=o,h=function(){if(!--a){var t=0;while(t<o)u[s[t]]=n.valueOf(e[s[t++]]);r.fulfill(u)}},p=function(e){r.reject(e)};return this.forEach(e,h,p,s),r},allResolved:function(e){var n=new t,r=f(e),i=r?l(e):c(e),s=i.length,o=r?[]:{};if(!s)return n.fulfill(o),n;var u=function(){--s||n.fulfill(e)};return this.forEach(e,u,u,i),n},any:function(e){var n=new t,r=e.length;if(!r)return n.reject(Error()),n;var i=0,s,o=function(e){n.fulfill(e)},u=function(e){i||(s=e),++i===r&&n.reject(s)};return this.forEach(e,o,u),n},delay:function(e,t,n){return this.promise(e).delay(t,n)},timeout:function(e,t){return this.promise(e).timeout(t)}},r,i=function(){if(typeof process=="object")return process.nextTick;if(e.setImmediate)return e.setImmediate;var t=[],n=function(){var e=t,n=0,r=t.length;t=[];while(n<r)e[n++]()};if(e.postMessage){var r=!0;if(e.attachEvent){var i=function(){r=!1};e.attachEvent("onmessage",i),e.postMessage("__checkAsync","*"),e.detachEvent("onmessage",i)}if(r){var s="__promise"+ +(new Date),o=function(e){e.data===s&&(e.stopPropagation&&e.stopPropagation(),n())};return e.addEventListener?e.addEventListener("message",o,!0):e.attachEvent("onmessage",o),function(n){t.push(n)===1&&e.postMessage(s,"*")}}}var u=e.document;if("onreadystatechange"in u.createElement("script")){var a=function(){var e=u.createElement("script");e.onreadystatechange=function(){e.parentNode.removeChild(e),e=e.onreadystatechange=null,n()},(u.documentElement||u.body).appendChild(e)};return function(e){t.push(e)===1&&a()}}return function(e){setTimeout(e,0)}}(),s=function(e){i(function(){throw e})},o=function(e){return typeof e=="function"},u=Array.prototype.slice,a=Object.prototype.toString,f=Array.isArray||function(e){return a.call(e)==="[object Array]"},l=function(e){var t=[],n=0,r=e.length;while(n<r)t.push(n++);return t},c=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t};typeof exports=="object"?module.exports=n:typeof define=="function"?define(function(e,t,r){r.exports=n}):e.Vow=n})(this);
* @version 0.2.6
*/(function(e){var t=function(e){this._res=e,this._isFulfilled=!!arguments.length,this._isRejected=!1,this._fulfilledCallbacks=[],this._rejectedCallbacks=[]};t.prototype={valueOf:function(){return this._res},isFulfilled:function(){return this._isFulfilled},isRejected:function(){return this._isRejected},isResolved:function(){return this._isFulfilled||this._isRejected},fulfill:function(e){if(this.isResolved())return;this._isFulfilled=!0,this._res=e,this._callCallbacks(this._fulfilledCallbacks),this._fulfilledCallbacks=this._rejectedCallbacks=r},reject:function(e){if(this.isResolved())return;this._isRejected=!0,this._res=e,this._callCallbacks(this._rejectedCallbacks),this._fulfilledCallbacks=this._rejectedCallbacks=r},then:function(e,n){var r=new t,i;return this._isRejected||(i={promise:r,fn:e},this._isFulfilled?this._callCallbacks([i]):this._fulfilledCallbacks.push(i)),this._isFulfilled||(i={promise:r,fn:n},this._isRejected?this._callCallbacks([i]):this._rejectedCallbacks.push(i)),r},fail:function(e){return this.then(r,e)},always:function(e){var t=this,n=function(){return e(t)};return this.then(n,n)},spread:function(e,t){return this.then(function(t){return e.apply(this,t)},t)},done:function(){this.fail(s)},delay:function(e){return this.then(function(n){var r=new t;return setTimeout(function(){r.fulfill(n)},e),r})},timeout:function(e){var n=new t,r=setTimeout(function(){n.reject(Error("timed out"))},e);return n.sync(this),n.always(function(){clearTimeout(r)}),n},sync:function(e){var t=this;e.then(function(e){t.fulfill(e)},function(e){t.reject(e)})},_callCallbacks:function(e){var t=e.length;if(!t)return;var r=this._res,s=this.isFulfilled();i(function(){var i=0,u,a,f;while(i<t){u=e[i++],a=u.promise,f=u.fn;if(o(f)){var l;try{l=f(r)}catch(c){a.reject(c);continue}n.isPromise(l)?function(e){l.then(function(t){e.fulfill(t)},function(t){e.reject(t)})}(a):a.fulfill(l)}else s?a.fulfill(r):a.reject(r)}})}};var n={promise:function(e){return arguments.length?this.isPromise(e)?e:new t(e):new t},when:function(e,t,n){return this.promise(e).then(t,n)},fail:function(e,t){return this.when(e,r,t)},always:function(e,t){return this.promise(e).always(t)},spread:function(e,t,n){return this.promise(e).spread(t,n)},done:function(e){this.isPromise(e)&&e.done()},isPromise:function(e){return e&&o(e.then)},valueOf:function(e){return this.isPromise(e)?e.valueOf():e},isFulfilled:function(e){return this.isPromise(e)?e.isFulfilled():!0},isRejected:function(e){return this.isPromise(e)?e.isRejected():!1},isResolved:function(e){return this.isPromise(e)?e.isResolved():!0},fulfill:function(e){return this.when(e,r,function(e){return e})},reject:function(e){return this.when(e,function(e){var n=new t;return n.reject(e),n})},resolve:function(e){return this.isPromise(e)?e:this.when(e)},invoke:function(e){try{return this.promise(e.apply(null,u.call(arguments,1)))}catch(t){return this.reject(t)}},forEach:function(e,t,n,r){var i=r?r.length:e.length,s=0;while(s<i)this.when(e[r?r[s]:s],t,n),++s},all:function(e){var r=new t,i=f(e),s=i?l(e):c(e),o=s.length,u=i?[]:{};if(!o)return r.fulfill(u),r;var a=o,h=function(){if(!--a){var t=0;while(t<o)u[s[t]]=n.valueOf(e[s[t++]]);r.fulfill(u)}},p=function(e){r.reject(e)};return this.forEach(e,h,p,s),r},allResolved:function(e){var n=new t,r=f(e),i=r?l(e):c(e),s=i.length,o=r?[]:{};if(!s)return n.fulfill(o),n;var u=function(){--s||n.fulfill(e)};return this.forEach(e,u,u,i),n},any:function(e){var n=new t,r=e.length;if(!r)return n.reject(Error()),n;var i=0,s,o=function(e){n.fulfill(e)},u=function(e){i||(s=e),++i===r&&n.reject(s)};return this.forEach(e,o,u),n},delay:function(e,t,n){return this.promise(e).delay(t,n)},timeout:function(e,t){return this.promise(e).timeout(t)}},r,i=function(){if(typeof process=="object")return process.nextTick;if(e.setImmediate)return e.setImmediate;var t=[],n=function(){var e=t,n=0,r=t.length;t=[];while(n<r)e[n++]()};if(e.postMessage){var r=!0;if(e.attachEvent){var i=function(){r=!1};e.attachEvent("onmessage",i),e.postMessage("__checkAsync","*"),e.detachEvent("onmessage",i)}if(r){var s="__promise"+ +(new Date),o=function(e){e.data===s&&(e.stopPropagation&&e.stopPropagation(),n())};return e.addEventListener?e.addEventListener("message",o,!0):e.attachEvent("onmessage",o),function(n){t.push(n)===1&&e.postMessage(s,"*")}}}var u=e.document;if("onreadystatechange"in u.createElement("script")){var a=function(){var e=u.createElement("script");e.onreadystatechange=function(){e.parentNode.removeChild(e),e=e.onreadystatechange=null,n()},(u.documentElement||u.body).appendChild(e)};return function(e){t.push(e)===1&&a()}}return function(e){setTimeout(e,0)}}(),s=function(e){i(function(){throw e})},o=function(e){return typeof e=="function"},u=Array.prototype.slice,a=Object.prototype.toString,f=Array.isArray||function(e){return a.call(e)==="[object Array]"},l=function(e){var t=[],n=0,r=e.length;while(n<r)t.push(n++);return t},c=Object.keys||function(e){var t=[];for(var n in e)e.hasOwnProperty(n)&&t.push(n);return t};typeof exports=="object"?module.exports=n:typeof define=="function"?define(function(e,t,r){r.exports=n}):e.Vow=n})(this);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc