MCPcopy Index your code
hub / github.com/components/jquery / adoptValue

Function adoptValue

jquery.js:3122–3150  ·  view source on GitHub ↗
( value, resolve, reject, noValue )

Source from the content-addressed store, hash-verified

3120}
3121
3122function adoptValue( value, resolve, reject, noValue ) {
3123 var method;
3124
3125 try {
3126
3127 // Check for promise aspect first to privilege synchronous behavior
3128 if ( value && typeof( method = value.promise ) === "function" ) {
3129 method.call( value ).done( resolve ).fail( reject );
3130
3131 // Other thenables
3132 } else if ( value && typeof( method = value.then ) === "function" ) {
3133 method.call( value, resolve, reject );
3134
3135 // Other non-thenables
3136 } else {
3137
3138 // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
3139 // * false: [ value ].slice( 0 ) => resolve( value )
3140 // * true: [ value ].slice( 1 ) => resolve()
3141 resolve.apply( undefined, [ value ].slice( noValue ) );
3142 }
3143
3144 // For Promises/A+, convert exceptions into rejections
3145 // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
3146 // Deferred#then to conditionally suppress rejection.
3147 } catch ( value ) {
3148 reject( value );
3149 }
3150}
3151
3152jQuery.extend( {
3153

Callers 1

jquery.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected