Skip to content

Commit

Permalink
[Promise, Node]: Build.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ezequiel Rodriguez committed Feb 19, 2014
1 parent 84ac438 commit 42f6a04
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 50 deletions.
2 changes: 1 addition & 1 deletion build/node-style/node-style-coverage.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions build/promise/promise-coverage.js

Large diffs are not rendered by default.

30 changes: 7 additions & 23 deletions build/promise/promise-debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,15 @@ in one.
This method can be copied or inherited in subclasses. In that case it will
check that the value passed to it is an instance of the correct class.
This means that `PromiseSubclass.cast()` will always return instances of
`PromiseSublcass`.
This means that `PromiseSubclass.resolve()` will always return instances of
`PromiseSubclass`.
@method cast
@method resolve
@param {Any} Any object that may or may not be a promise
@return {Promise}
@static
*/
Promise.cast = function (value) {
Promise.resolve = function (value) {
return Promise.isPromise(value) && value.constructor === this ? value :
/*jshint newcap: false */
new this(function (resolve) {
Expand All @@ -249,22 +249,6 @@ Promise.reject = function (reason) {
});
};

/*
A shorthand for creating a resolved promise.
@method resolve
@param {Any} value The value or promise that resolves the returned promise
@return {Promise} A resolved promise
@static
*/
Promise.resolve = function (value) {
/*jshint newcap: false */
return new this(function (resolve) {
/*jshint newcap: true */
resolve(value);
});
};

/*
Returns a promise that is resolved or rejected when all values are resolved or
any is rejected. This is useful for waiting for the resolution of multiple
Expand Down Expand Up @@ -306,7 +290,7 @@ Promise.all = function (values) {
}

for (; i < length; i++) {
Promise.cast(values[i]).then(oneDone(i), reject);
Promise.resolve(values[i]).then(oneDone(i), reject);
}
});
};
Expand All @@ -333,7 +317,7 @@ Promise.race = function (values) {
// This abuses the fact that calling resolve/reject multiple times
// doesn't change the state of the returned promise
for (var i = 0, count = values.length; i < count; i++) {
Promise.cast(values[i]).then(resolve, reject);
Promise.resolve(values[i]).then(resolve, reject);
}
});
};
Expand Down Expand Up @@ -612,7 +596,7 @@ are provided, the original promise is returned.
@return {Promise}
**/
Y.when = function (promise, callback, errback) {
promise = Promise.cast(promise);
promise = Promise.resolve(promise);

return (callback || errback) ? promise.then(callback, errback) : promise;
};
Expand Down
2 changes: 1 addition & 1 deletion build/promise/promise-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions build/promise/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,15 +214,15 @@ in one.
This method can be copied or inherited in subclasses. In that case it will
check that the value passed to it is an instance of the correct class.
This means that `PromiseSubclass.cast()` will always return instances of
`PromiseSublcass`.
This means that `PromiseSubclass.resolve()` will always return instances of
`PromiseSubclass`.
@method cast
@method resolve
@param {Any} Any object that may or may not be a promise
@return {Promise}
@static
*/
Promise.cast = function (value) {
Promise.resolve = function (value) {
return Promise.isPromise(value) && value.constructor === this ? value :
/*jshint newcap: false */
new this(function (resolve) {
Expand All @@ -248,22 +248,6 @@ Promise.reject = function (reason) {
});
};

/*
A shorthand for creating a resolved promise.
@method resolve
@param {Any} value The value or promise that resolves the returned promise
@return {Promise} A resolved promise
@static
*/
Promise.resolve = function (value) {
/*jshint newcap: false */
return new this(function (resolve) {
/*jshint newcap: true */
resolve(value);
});
};

/*
Returns a promise that is resolved or rejected when all values are resolved or
any is rejected. This is useful for waiting for the resolution of multiple
Expand Down Expand Up @@ -305,7 +289,7 @@ Promise.all = function (values) {
}

for (; i < length; i++) {
Promise.cast(values[i]).then(oneDone(i), reject);
Promise.resolve(values[i]).then(oneDone(i), reject);
}
});
};
Expand All @@ -332,7 +316,7 @@ Promise.race = function (values) {
// This abuses the fact that calling resolve/reject multiple times
// doesn't change the state of the returned promise
for (var i = 0, count = values.length; i < count; i++) {
Promise.cast(values[i]).then(resolve, reject);
Promise.resolve(values[i]).then(resolve, reject);
}
});
};
Expand Down Expand Up @@ -609,7 +593,7 @@ are provided, the original promise is returned.
@return {Promise}
**/
Y.when = function (promise, callback, errback) {
promise = Promise.cast(promise);
promise = Promise.resolve(promise);

return (callback || errback) ? promise.then(callback, errback) : promise;
};
Expand Down

0 comments on commit 42f6a04

Please sign in to comment.