Skip to content

Commit ecc97e5

Browse files
committed
Deferred: Reduce size
1 parent d8b1408 commit ecc97e5

File tree

1 file changed

+24
-28
lines changed

1 file changed

+24
-28
lines changed

src/deferred.js

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -256,51 +256,47 @@ jQuery.extend( {
256256
var list = tuple[ 2 ],
257257
stateString = tuple[ 5 ];
258258

259-
// promise.progress = list.add
260-
// promise.done = list.add
261-
// promise.fail = list.add
262-
promise[ tuple[ 1 ] ] = list.add;
263-
264-
// Handle state
265-
if ( stateString ) {
266-
list.add(
267-
function() {
259+
list.add( function() {
268260

269-
// state = "resolved" (i.e., fulfilled)
270-
// state = "rejected"
271-
state = stateString;
272-
},
261+
// Handle state
262+
if ( stateString ) {
273263

274-
// rejected_callbacks.disable
275-
// fulfilled_callbacks.disable
276-
tuples[ 3 - i ][ 2 ].disable,
264+
// state = "resolved" (i.e., fulfilled)
265+
// state = "rejected"
266+
state = stateString;
277267

278268
// progress_callbacks.lock
279-
tuples[ 0 ][ 2 ].lock
280-
);
281-
}
269+
tuples[ 0 ][ 2 ].lock();
282270

283-
// progress_handlers.fire
284-
// fulfilled_handlers.fire
285-
// rejected_handlers.fire
286-
list.add( function() {
271+
// rejected_callbacks.disable
272+
// fulfilled_callbacks.disable
273+
tuples[ 3 - i ][ 2 ].disable();
274+
}
287275

288276
// Fire .then handlers, recovering null/undefined context from global `this`
277+
// progress_handlers.fire
278+
// fulfilled_handlers.fire
279+
// rejected_handlers.fire
289280
tuple[ 3 ].fireWith( list.context, arguments );
290281
} );
291282

283+
// promise.progress = list.add
284+
// promise.done = list.add
285+
// promise.fail = list.add
286+
promise[ tuple[ 1 ] ] = list.add;
287+
288+
// deferred.notifyWith = list.fireWith
289+
// deferred.resolveWith = list.fireWith
290+
// deferred.rejectWith = list.fireWith
291+
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
292+
292293
// deferred.notify = function() { deferred.notifyWith(...) }
293294
// deferred.resolve = function() { deferred.resolveWith(...) }
294295
// deferred.reject = function() { deferred.rejectWith(...) }
295296
deferred[ tuple[ 0 ] ] = function() {
296297
deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
297298
return this;
298299
};
299-
300-
// deferred.notifyWith = list.fireWith
301-
// deferred.resolveWith = list.fireWith
302-
// deferred.rejectWith = list.fireWith
303-
deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
304300
} );
305301

306302
// Make the deferred a promise

0 commit comments

Comments
 (0)