Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kflorence/jquery-deferred-sequence
Sequentially process a value through a list of jQuery Deferred objects.
https://github.com/kflorence/jquery-deferred-sequence
Last synced: 3 days ago
JSON representation
Sequentially process a value through a list of jQuery Deferred objects.
- Host: GitHub
- URL: https://github.com/kflorence/jquery-deferred-sequence
- Owner: kflorence
- License: gpl-2.0
- Created: 2013-01-20T04:55:24.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-12-31T22:58:58.000Z (almost 8 years ago)
- Last Synced: 2024-12-01T09:12:45.823Z (22 days ago)
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license-gpl
Awesome Lists containing this project
README
# jQuery Deferred Sequence
Allows a value to be sequentially processed through a list of objects, usually
[Deferred](http://api.jquery.com/category/deferred-object/) objects that represent asynchronous events.```javascript
var value = 0,
items = [
function( value ) {
return value + 1;
},
function( value ) {
var dfd = $.Deferred();setTimeout(function() {
dfd.resolve( value * 2 );
}, 1000 );return dfd;
},
function( value ) {
return value * value;
}
],
sequence = $.Deferred.Sequence( items );sequence.reduce( value, function( func, value ) {
return $.when( func( value ) );}).done(function( value ) {
console.log( value ); // => 4
});
```## Methods
* **reduce(** [ _intialValue_, ] _callbackFunction_ [, _context_ ] **)** _Promise_
Apply a function against each item in the sequence, optionally calling
the function with the specified context.## Properties
* **head** _Deferred_
A deferred object representing the beginning of the sequence.* **items** _Array_, _Object_
The items given to the sequence on initialization.* **master** _Deferred_
A deferred object which tracks the aggregate state of all the deferreds
in the sequence.* **tail** _Deferred_
A deferred object representing the end of the sequence.## License
Copyright (c) 2013 Kyle Florence
Dual licensed under the MIT and GPLv2 licenses.