MCPcopy
hub / github.com/layui/layui / adoptValue

Function adoptValue

src/modules/jquery.js:3452–3480  ·  view source on GitHub ↗
(value, resolve, reject, noValue)

Source from the content-addressed store, hash-verified

3450 }
3451
3452 function adoptValue(value, resolve, reject, noValue) {
3453 var method;
3454
3455 try {
3456 // Check for promise aspect first to privilege synchronous behavior
3457 if (value && isFunction((method = value.promise))) {
3458 method.call(value).done(resolve).fail(reject);
3459
3460 // Other thenables
3461 } else if (value && isFunction((method = value.then))) {
3462 method.call(value, resolve, reject);
3463
3464 // Other non-thenables
3465 } else {
3466 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3467 // * false: [ value ].slice( 0 ) => resolve( value )
3468 // * true: [ value ].slice( 1 ) => resolve()
3469 resolve.apply(undefined, [value].slice(noValue));
3470 }
3471
3472 // For Promises/A+, convert exceptions into rejections
3473 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3474 // Deferred#then to conditionally suppress rejection.
3475 } catch (value) {
3476 // Support: Android 4.0 only
3477 // Strict mode functions invoked without .call/.apply get global-object context
3478 reject.apply(undefined, [value]);
3479 }
3480 }
3481
3482 jQuery.extend({
3483 Deferred: function (func) {

Callers 1

jquery.jsFile · 0.85

Calls 1

isFunctionFunction · 0.85

Tested by

no test coverage detected