Skip to content

Commit

Permalink
Deferred: Rename master to primary
Browse files Browse the repository at this point in the history
Closes gh-4828

(cherry picked from a32cf63)
  • Loading branch information
mgol committed Jan 12, 2021
1 parent 7298e04 commit 15b62a2
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/deferred.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,39 +359,39 @@ jQuery.extend( {
resolveContexts = Array( i ),
resolveValues = slice.call( arguments ),

// the master Deferred
master = jQuery.Deferred(),
// the primary Deferred
primary = jQuery.Deferred(),

// subordinate callback factory
updateFunc = function( i ) {
return function( value ) {
resolveContexts[ i ] = this;
resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
if ( !( --remaining ) ) {
master.resolveWith( resolveContexts, resolveValues );
primary.resolveWith( resolveContexts, resolveValues );
}
};
};

// Single- and empty arguments are adopted like Promise.resolve
if ( remaining <= 1 ) {
adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
adoptValue( singleValue, primary.done( updateFunc( i ) ).resolve, primary.reject,
!remaining );

// Use .then() to unwrap secondary thenables (cf. gh-3000)
if ( master.state() === "pending" ||
if ( primary.state() === "pending" ||
isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {

return master.then();
return primary.then();
}
}

// Multiple arguments are aggregated like Promise.all array elements
while ( i-- ) {
adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
adoptValue( resolveValues[ i ], updateFunc( i ), primary.reject );
}

return master.promise();
return primary.promise();
}
} );

Expand Down

0 comments on commit 15b62a2

Please sign in to comment.