Comparing version 0.4.9 to 0.4.10
Changelog | ||
========= | ||
0.4.9 | ||
----- | ||
* `vow.cast` method was fixed to properly work with external promises [#88](https://github.com/dfilatov/vow/issues/88) | ||
0.4.8 | ||
@@ -4,0 +8,0 @@ ----- |
178
lib/vow.js
/** | ||
* @module vow | ||
* @author Filatov Dmitry <dfilatov@yandex-team.ru> | ||
* @version 0.4.9 | ||
* @version 0.4.10 | ||
* @license | ||
@@ -39,3 +39,15 @@ * Dual licensed under the MIT and GPL licenses: | ||
if(global.postMessage) { // modern browsers | ||
var MutationObserver = global.MutationObserver || global.WebKitMutationObserver; // modern browsers | ||
if(MutationObserver) { | ||
var num = 1, | ||
node = document.createTextNode(''); | ||
new MutationObserver(callFns).observe(node, { characterData : true }); | ||
return function(fn) { | ||
enqueueFn(fn) && (node.data = (num *= -1)); | ||
}; | ||
} | ||
if(global.postMessage) { | ||
var isPostMessageAsync = true; | ||
@@ -157,3 +169,3 @@ if(global.attachEvent) { | ||
/** | ||
* Returns corresponding promise. | ||
* Returns the corresponding promise. | ||
* | ||
@@ -167,3 +179,3 @@ * @returns {vow:Promise} | ||
/** | ||
* Resolves corresponding promise with given `value`. | ||
* Resolves the corresponding promise with the given `value`. | ||
* | ||
@@ -189,3 +201,3 @@ * @param {*} value | ||
/** | ||
* Rejects corresponding promise with given `reason`. | ||
* Rejects the corresponding promise with the given `reason`. | ||
* | ||
@@ -225,3 +237,3 @@ * @param {*} reason | ||
/** | ||
* Notifies corresponding promise with given `value`. | ||
* Notifies the corresponding promise with the given `value`. | ||
* | ||
@@ -320,3 +332,3 @@ * @param {*} value | ||
/** | ||
* Returns value of fulfilled promise or reason in case of rejection. | ||
* Returns the value of the fulfilled promise or the reason in case of rejection. | ||
* | ||
@@ -330,3 +342,3 @@ * @returns {*} | ||
/** | ||
* Returns `true` if promise is resolved. | ||
* Returns `true` if the promise is resolved. | ||
* | ||
@@ -340,3 +352,3 @@ * @returns {Boolean} | ||
/** | ||
* Returns `true` if promise is fulfilled. | ||
* Returns `true` if the promise is fulfilled. | ||
* | ||
@@ -350,3 +362,3 @@ * @returns {Boolean} | ||
/** | ||
* Returns `true` if promise is rejected. | ||
* Returns `true` if the promise is rejected. | ||
* | ||
@@ -360,8 +372,8 @@ * @returns {Boolean} | ||
/** | ||
* Adds reactions to promise. | ||
* Adds reactions to the promise. | ||
* | ||
* @param {Function} [onFulfilled] Callback that will to be invoked with the value after promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Function} [onProgress] Callback that will to be invoked with the value after promise has been notified | ||
* @param {Object} [ctx] Context of callbacks execution | ||
* @param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Function} [onProgress] Callback that will be invoked with a provided value after the promise has been notified | ||
* @param {Object} [ctx] Context of the callbacks execution | ||
* @returns {vow:Promise} A new promise, see https://github.com/promises-aplus/promises-spec for details | ||
@@ -376,6 +388,6 @@ */ | ||
/** | ||
* Adds rejection reaction only. It is shortcut for `promise.then(undefined, onRejected)`. | ||
* Adds only a rejection reaction. This method is a shorthand for `promise.then(undefined, onRejected)`. | ||
* | ||
* @param {Function} onRejected Callback to be called with the value after promise has been rejected | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Function} onRejected Callback that will be called with a provided 'reason' as argument after the promise has been rejected | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -388,6 +400,6 @@ */ | ||
/** | ||
* Adds rejection reaction only. It is shortcut for `promise.then(null, onRejected)`. It's alias for `catch`. | ||
* Adds only a rejection reaction. This method is a shorthand for `promise.then(null, onRejected)`. It's also an alias for `catch`. | ||
* | ||
* @param {Function} onRejected Callback to be called with the value after promise has been rejected | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -400,6 +412,6 @@ */ | ||
/** | ||
* Adds resolving reaction (to fulfillment and rejection both). | ||
* Adds a resolving reaction (for both fulfillment and rejection). | ||
* | ||
* @param {Function} onResolved Callback that to be called with the value after promise has been resolved | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Function} onResolved Callback that will be invoked with the promise as an argument, after the promise has been resolved. | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -417,6 +429,6 @@ */ | ||
/** | ||
* Adds progress reaction. | ||
* Adds a progress reaction. | ||
* | ||
* @param {Function} onProgress Callback to be called with the value when promise has been notified | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Function} onProgress Callback that will be called with a provided value when the promise has been notified | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -430,7 +442,7 @@ */ | ||
* Like `promise.then`, but "spreads" the array into a variadic value handler. | ||
* It is useful with `vow.all` and `vow.allResolved` methods. | ||
* It is useful with the `vow.all` and the `vow.allResolved` methods. | ||
* | ||
* @param {Function} [onFulfilled] Callback that will to be invoked with the value after promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Object} [ctx] Context of callbacks execution | ||
* @param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Object} [ctx] Context of the callbacks execution | ||
* @returns {vow:Promise} | ||
@@ -462,8 +474,8 @@ * | ||
* Like `then`, but terminates a chain of promises. | ||
* If the promise has been rejected, throws it as an exception in a future turn of the event loop. | ||
* If the promise has been rejected, this method throws it's "reason" as an exception in a future turn of the event loop. | ||
* | ||
* @param {Function} [onFulfilled] Callback that will to be invoked with the value after promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Function} [onProgress] Callback that will to be invoked with the value after promise has been notified | ||
* @param {Object} [ctx] Context of callbacks execution | ||
* @param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Function} [onProgress] Callback that will be invoked with a provided value after the promise has been notified | ||
* @param {Object} [ctx] Context of the callbacks execution | ||
* | ||
@@ -485,3 +497,3 @@ * @example | ||
* Returns a new promise that will be fulfilled in `delay` milliseconds if the promise is fulfilled, | ||
* or immediately rejected if promise is rejected. | ||
* or immediately rejected if the promise is rejected. | ||
* | ||
@@ -742,3 +754,3 @@ * @param {Number} delay | ||
/** | ||
* Coerces given `value` to a promise, or returns the `value` if it's already a promise. | ||
* Coerces the given `value` to a promise, or returns the `value` if it's already a promise. | ||
* | ||
@@ -753,4 +765,4 @@ * @param {*} value | ||
/** | ||
* Returns a promise to be fulfilled only after all the items in `iterable` are fulfilled, | ||
* or to be rejected when any of the `iterable` is rejected. | ||
* Returns a promise, that will be fulfilled only after all the items in `iterable` are fulfilled. | ||
* If any of the `iterable` items gets rejected, then the returned promise will be rejected. | ||
* | ||
@@ -765,4 +777,4 @@ * @param {Array|Object} iterable | ||
/** | ||
* Returns a promise to be fulfilled only when any of the items in `iterable` are fulfilled, | ||
* or to be rejected when the first item is rejected. | ||
* Returns a promise, that will be fulfilled only when any of the items in `iterable` are fulfilled. | ||
* If any of the `iterable` items gets rejected, then the returned promise will be rejected. | ||
* | ||
@@ -778,3 +790,3 @@ * @param {Array} iterable | ||
* Returns a promise that has already been resolved with the given `value`. | ||
* If `value` is a promise, returned promise will be adopted with the state of given promise. | ||
* If `value` is a promise, the returned promise will have `value`'s state. | ||
* | ||
@@ -821,9 +833,9 @@ * @param {*} value | ||
* Static equivalent to `promise.then`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
* @param {*} value | ||
* @param {Function} [onFulfilled] Callback that will to be invoked with the value after promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Function} [onProgress] Callback that will to be invoked with the value after promise has been notified | ||
* @param {Object} [ctx] Context of callbacks execution | ||
* @param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Function} [onProgress] Callback that will be invoked with a provided value after the promise has been notified | ||
* @param {Object} [ctx] Context of the callbacks execution | ||
* @returns {vow:Promise} | ||
@@ -837,7 +849,7 @@ */ | ||
* Static equivalent to `promise.fail`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
* @param {*} value | ||
* @param {Function} onRejected Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Function} onRejected Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -851,7 +863,7 @@ */ | ||
* Static equivalent to `promise.always`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
* @param {*} value | ||
* @param {Function} onResolved Callback that will to be invoked with the reason after promise has been resolved | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Function} onResolved Callback that will be invoked with the promise as an argument, after the promise has been resolved. | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -865,7 +877,7 @@ */ | ||
* Static equivalent to `promise.progress`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
* @param {*} value | ||
* @param {Function} onProgress Callback that will to be invoked with the reason after promise has been notified | ||
* @param {Object} [ctx] Context of callback execution | ||
* @param {Function} onProgress Callback that will be invoked with a provided value after the promise has been notified | ||
* @param {Object} [ctx] Context of the callback execution | ||
* @returns {vow:Promise} | ||
@@ -879,8 +891,8 @@ */ | ||
* Static equivalent to `promise.spread`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
* @param {*} value | ||
* @param {Function} [onFulfilled] Callback that will to be invoked with the value after promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Object} [ctx] Context of callbacks execution | ||
* @param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Object} [ctx] Context of the callbacks execution | ||
* @returns {vow:Promise} | ||
@@ -894,9 +906,9 @@ */ | ||
* Static equivalent to `promise.done`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
* @param {*} value | ||
* @param {Function} [onFulfilled] Callback that will to be invoked with the value after promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will to be invoked with the reason after promise has been rejected | ||
* @param {Function} [onProgress] Callback that will to be invoked with the value after promise has been notified | ||
* @param {Object} [ctx] Context of callbacks execution | ||
* @param {Function} [onFulfilled] Callback that will be invoked with a provided value after the promise has been fulfilled | ||
* @param {Function} [onRejected] Callback that will be invoked with a provided reason after the promise has been rejected | ||
* @param {Function} [onProgress] Callback that will be invoked with a provided value after the promise has been notified | ||
* @param {Object} [ctx] Context of the callbacks execution | ||
*/ | ||
@@ -925,3 +937,3 @@ done : function(value, onFulfilled, onRejected, onProgress, ctx) { | ||
/** | ||
* Coerces given `value` to a promise, or returns the `value` if it's already a promise. | ||
* Coerces the given `value` to a promise, or returns the `value` if it's already a promise. | ||
* | ||
@@ -939,3 +951,3 @@ * @param {*} value | ||
* Static equivalent to `promise.valueOf`. | ||
* If given `value` is not an instance of `vow.Promise`, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
@@ -951,3 +963,3 @@ * @param {*} value | ||
* Static equivalent to `promise.isFulfilled`. | ||
* If given `value` is not an instance of `vow.Promise`, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
@@ -963,3 +975,3 @@ * @param {*} value | ||
* Static equivalent to `promise.isRejected`. | ||
* If given `value` is not an instance of `vow.Promise`, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
@@ -975,3 +987,3 @@ * @param {*} value | ||
* Static equivalent to `promise.isResolved`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
@@ -987,3 +999,3 @@ * @param {*} value | ||
* Returns a promise that has already been resolved with the given `value`. | ||
* If `value` is a promise, returned promise will be adopted with the state of given promise. | ||
* If `value` is a promise, the returned promise will have `value`'s state. | ||
* | ||
@@ -1001,3 +1013,3 @@ * @param {*} value | ||
* Returns a promise that has already been fulfilled with the given `value`. | ||
* If `value` is a promise, returned promise will be fulfilled with fulfill/rejection value of given promise. | ||
* If `value` is a promise, the returned promise will be fulfilled with the fulfill/rejection value of `value`. | ||
* | ||
@@ -1022,3 +1034,3 @@ * @param {*} value | ||
* Returns a promise that has already been rejected with the given `reason`. | ||
* If `reason` is a promise, returned promise will be rejected with fulfill/rejection value of given promise. | ||
* If `reason` is a promise, the returned promise will be rejected with the fulfill/rejection value of `reason`. | ||
* | ||
@@ -1035,3 +1047,3 @@ * @param {*} reason | ||
/** | ||
* Invokes a given function `fn` with arguments `args` | ||
* Invokes the given function `fn` with arguments `args` | ||
* | ||
@@ -1079,4 +1091,4 @@ * @param {Function} fn | ||
/** | ||
* Returns a promise to be fulfilled only after all the items in `iterable` are fulfilled, | ||
* or to be rejected when any of the `iterable` is rejected. | ||
* Returns a promise, that will be fulfilled only after all the items in `iterable` are fulfilled. | ||
* If any of the `iterable` items gets rejected, the promise will be rejected. | ||
* | ||
@@ -1148,3 +1160,3 @@ * @param {Array|Object} iterable | ||
/** | ||
* Returns a promise to be fulfilled only after all the items in `iterable` are resolved. | ||
* Returns a promise, that will be fulfilled only after all the items in `iterable` are resolved. | ||
* | ||
@@ -1235,4 +1247,4 @@ * @param {Array|Object} iterable | ||
/** | ||
* Returns a promise to be fulfilled only when any of the items in `iterable` is fulfilled, | ||
* or to be rejected when all the items are rejected (with the reason of the first rejected item). | ||
* Returns a promise, that will be fulfilled if any of the items in `iterable` is fulfilled. | ||
* If all of the `iterable` items get rejected, the promise will be rejected (with the reason of the first rejected item). | ||
* | ||
@@ -1266,4 +1278,4 @@ * @param {Array} iterable | ||
/** | ||
* Returns a promise to be fulfilled only when any of the items in `iterable` is fulfilled, | ||
* or to be rejected when the first item is rejected. | ||
* Returns a promise, that will be fulfilled only when any of the items in `iterable` is fulfilled. | ||
* If any of the `iterable` items gets rejected, the promise will be rejected. | ||
* | ||
@@ -1294,3 +1306,3 @@ * @param {Array} iterable | ||
* Static equivalent to `promise.delay`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
@@ -1307,3 +1319,3 @@ * @param {*} value | ||
* Static equivalent to `promise.timeout`. | ||
* If given `value` is not a promise, then `value` is equivalent to fulfilled promise. | ||
* If `value` is not a promise, then `value` is treated as a fulfilled promise. | ||
* | ||
@@ -1310,0 +1322,0 @@ * @param {*} value |
{ | ||
"name" : "vow", | ||
"version" : "0.4.9", | ||
"version" : "0.4.10", | ||
"description" : "DOM Promise and Promises/A+ implementation for Node.js and browsers", | ||
@@ -5,0 +5,0 @@ "homepage" : "http://dfilatov.github.io/vow/", |
@@ -1,5 +0,3 @@ | ||
**NOTE**. Documentation for old versions of the library can be found at https://github.com/dfilatov/vow/blob/0.3.x/README.md. | ||
<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> | ||
Vow 0.4.8 [![NPM version](https://badge.fury.io/js/vow.png)](http://badge.fury.io/js/vow) [![Build Status](https://secure.travis-ci.org/dfilatov/vow.png)](http://travis-ci.org/dfilatov/vow) | ||
Vow 0.4.9 [![NPM version](https://badge.fury.io/js/vow.png)](http://badge.fury.io/js/vow) [![Build Status](https://secure.travis-ci.org/dfilatov/vow.png)](http://travis-ci.org/dfilatov/vow) | ||
========= | ||
@@ -10,2 +8,4 @@ | ||
Full API reference can be found at http://dfilatov.github.io/vow/. | ||
Getting Started | ||
@@ -64,5 +64,2 @@ --------------- | ||
Full API reference can be found at http://dfilatov.github.io/vow/. | ||
Extensions and related projects | ||
@@ -74,1 +71,3 @@ ------------------------------- | ||
* [vow-asker](https://github.com/nodules/vow-asker) — wraps [asker](https://github.com/nodules/asker) API in the vow promises implementation | ||
**NOTE**. Documentation for old versions of the library can be found at https://github.com/dfilatov/vow/blob/0.3.x/README.md. |
56381
6
1198
71