Please enable JavaScript to use RhodeCode Enterprise
Commit Description:
merge
Commit Description:
merge
"use strict" ;
var isFunction = require ( "../function/is-function" );
module . exports = function ( executor ) {
var Constructor ;
if ( isFunction ( this )) {
Constructor = this ;
} else if ( typeof Promise === "function" ) {
Constructor = Promise ;
} else {
throw new TypeError ( "Could not resolve Promise constuctor" );
}
var lazyThen ;
var promise = new Constructor ( function ( resolve , reject ) {
lazyThen = function ( onSuccess , onFailure ) {
if ( ! hasOwnProperty . call ( this , "then" )) {
// Sanity check
throw new Error ( "Unexpected (inherited) lazy then invocation" );
}
try { executor ( resolve , reject ); }
catch ( reason ) { reject ( reason ); }
delete this . then ;
return this . then ( onSuccess , onFailure );
};
});
return Object . defineProperty ( promise , "then" , {
configurable : true ,
writable : true ,
value : lazyThen
});
};
Site-wide shortcuts
/
Use quick search box
g h
Goto home page
g g
Goto my private gists page
g G
Goto my public gists page
n r
New repository page
n g
New gist page
Repositories
g s
Goto summary page
g c
Goto changelog page
g f
Goto files page
g F
Goto files page with file search activated
g p
Goto pull requests page
g o
Goto repository settings
g O
Goto repository permissions settings