( value, resolve, reject, noValue )
| 3380 | } |
| 3381 | |
| 3382 | function adoptValue( value, resolve, reject, noValue ) { |
| 3383 | var method; |
| 3384 | |
| 3385 | try { |
| 3386 | |
| 3387 | // Check for promise aspect first to privilege synchronous behavior |
| 3388 | if ( value && isFunction( ( method = value.promise ) ) ) { |
| 3389 | method.call( value ).done( resolve ).fail( reject ); |
| 3390 | |
| 3391 | // Other thenables |
| 3392 | } else if ( value && isFunction( ( method = value.then ) ) ) { |
| 3393 | method.call( value, resolve, reject ); |
| 3394 | |
| 3395 | // Other non-thenables |
| 3396 | } else { |
| 3397 | |
| 3398 | // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: |
| 3399 | // * false: [ value ].slice( 0 ) => resolve( value ) |
| 3400 | // * true: [ value ].slice( 1 ) => resolve() |
| 3401 | resolve.apply( undefined, [ value ].slice( noValue ) ); |
| 3402 | } |
| 3403 | |
| 3404 | // For Promises/A+, convert exceptions into rejections |
| 3405 | // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in |
| 3406 | // Deferred#then to conditionally suppress rejection. |
| 3407 | } catch ( value ) { |
| 3408 | |
| 3409 | // Support: Android 4.0 only |
| 3410 | // Strict mode functions invoked without .call/.apply get global-object context |
| 3411 | reject.apply( undefined, [ value ] ); |
| 3412 | } |
| 3413 | } |
| 3414 | |
| 3415 | jQuery.extend( { |
| 3416 |
no test coverage detected