( value, resolve, reject, noValue )
| 3657 | } |
| 3658 | |
| 3659 | function adoptValue( value, resolve, reject, noValue ) { |
| 3660 | var method; |
| 3661 | |
| 3662 | try { |
| 3663 | |
| 3664 | // Check for promise aspect first to privilege synchronous behavior |
| 3665 | if ( value && isFunction( ( method = value.promise ) ) ) { |
| 3666 | method.call( value ).done( resolve ).fail( reject ); |
| 3667 | |
| 3668 | // Other thenables |
| 3669 | } else if ( value && isFunction( ( method = value.then ) ) ) { |
| 3670 | method.call( value, resolve, reject ); |
| 3671 | |
| 3672 | // Other non-thenables |
| 3673 | } else { |
| 3674 | |
| 3675 | // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer: |
| 3676 | // * false: [ value ].slice( 0 ) => resolve( value ) |
| 3677 | // * true: [ value ].slice( 1 ) => resolve() |
| 3678 | resolve.apply( undefined, [ value ].slice( noValue ) ); |
| 3679 | } |
| 3680 | |
| 3681 | // For Promises/A+, convert exceptions into rejections |
| 3682 | // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in |
| 3683 | // Deferred#then to conditionally suppress rejection. |
| 3684 | } catch ( value ) { |
| 3685 | |
| 3686 | // Support: Android 4.0 only |
| 3687 | // Strict mode functions invoked without .call/.apply get global-object context |
| 3688 | reject.apply( undefined, [ value ] ); |
| 3689 | } |
| 3690 | } |
| 3691 | |
| 3692 | jQuery.extend( { |
| 3693 |
no test coverage detected