Deferred: Rename master to primary

Closes gh-4828
This commit is contained in:
Michał Gołębiowski-Owczarek 2021-01-12 20:56:51 +01:00 committed by GitHub
parent d38528b17a
commit a32cf6324f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -353,8 +353,8 @@ jQuery.extend( {
resolveContexts = Array( i ), resolveContexts = Array( i ),
resolveValues = slice.call( arguments ), resolveValues = slice.call( arguments ),
// the master Deferred // the primary Deferred
master = jQuery.Deferred(), primary = jQuery.Deferred(),
// subordinate callback factory // subordinate callback factory
updateFunc = function( i ) { updateFunc = function( i ) {
@ -362,30 +362,30 @@ jQuery.extend( {
resolveContexts[ i ] = this; resolveContexts[ i ] = this;
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value; resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( !( --remaining ) ) { if ( !( --remaining ) ) {
master.resolveWith( resolveContexts, resolveValues ); primary.resolveWith( resolveContexts, resolveValues );
} }
}; };
}; };
// Single- and empty arguments are adopted like Promise.resolve // Single- and empty arguments are adopted like Promise.resolve
if ( remaining <= 1 ) { if ( remaining <= 1 ) {
adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject, adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
!remaining ); !remaining );
// Use .then() to unwrap secondary thenables (cf. gh-3000) // Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( master.state() === "pending" || if ( primary.state() === "pending" ||
typeof( resolveValues[ i ] && resolveValues[ i ].then ) === "function" ) { typeof( resolveValues[ i ] && resolveValues[ i ].then ) === "function" ) {
return master.then(); return primary.then();
} }
} }
// Multiple arguments are aggregated like Promise.all array elements // Multiple arguments are aggregated like Promise.all array elements
while ( i-- ) { while ( i-- ) {
adoptValue( resolveValues[ i ], updateFunc( i ), master.reject ); adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
} }
return master.promise(); return primary.promise();
} }
} ); } );