@@ -26,11 +26,15 @@ var isPromisesAPlusCompliant = true;
2626 * @constructor
2727 */
2828export default class ParsePromise {
29- constructor ( ) {
29+ constructor ( executor ) {
3030 this . _resolved = false ;
3131 this . _rejected = false ;
3232 this . _resolvedCallbacks = [ ] ;
3333 this . _rejectedCallbacks = [ ] ;
34+
35+ if ( typeof executor === 'function' ) {
36+ executor ( this . resolve . bind ( this ) , this . reject . bind ( this ) ) ;
37+ }
3438 }
3539
3640 /**
@@ -301,6 +305,26 @@ export default class ParsePromise {
301305 return promise ;
302306 }
303307
308+ /**
309+ * Returns a new promise that is resolved with a given value.
310+ * If that value is a thenable Promise (has a .then() prototype
311+ * method), the new promise will be chained to the end of the
312+ * value.
313+ * @method resolve
314+ * @param value The value to resolve the promise with
315+ * @static
316+ * @return {Parse.Promise } the new promise.
317+ */
318+ static resolve ( value ) {
319+ return new ParsePromise ( ( resolve , reject ) => {
320+ if ( ParsePromise . is ( value ) ) {
321+ value . then ( resolve , reject ) ;
322+ } else {
323+ resolve ( value ) ;
324+ }
325+ } ) ;
326+ }
327+
304328 /**
305329 * Returns a new promise that is rejected with a given error.
306330 * @method error
@@ -314,6 +338,19 @@ export default class ParsePromise {
314338 return promise ;
315339 }
316340
341+ /**
342+ * Returns a new promise that is rejected with a given error.
343+ * This is an alias for Parse.Promise.error, for compliance with
344+ * the ES6 implementation.
345+ * @method reject
346+ * @param error The error to reject the promise with
347+ * @static
348+ * @return {Parse.Promise } the new promise.
349+ */
350+ static reject ( ...errors ) {
351+ return ParsePromise . error . apply ( null , errors ) ;
352+ }
353+
317354 /**
318355 * Returns a new promise that is fulfilled when all of the input promises
319356 * are resolved. If any promise in the list fails, then the returned promise
0 commit comments