Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
05882104
Commit
05882104
authored
Aug 23, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Promise first updated
parent
595b119e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
src/jio/core/Promise.js
src/jio/core/Promise.js
+5
-5
No files found.
src/jio/core/Promise.js
View file @
05882104
...
...
@@ -225,21 +225,21 @@ Promise.any = function (items) {
};
/**
* first(
*
items): Promise
* first(items): Promise
*
* Resolve the promise only when one item is resolved. The item type must be
* like the item parameter of the `when` static method.
*
* Promise.first(
Promise.delay(100), 'b'
).then(console.log); // shows 'b'
* Promise.first(
[Promise.delay(100), 'b']
).then(console.log); // shows 'b'
*
* @method first
* @static
* @param {A
ny} *
items The items to use
* @param {A
rray}
items The items to use
* @return {Promise} The promise
*/
Promise
.
first
=
function
()
{
// *promises
Promise
.
first
=
function
(
items
)
{
// *promises
var
next
=
new
Promise
(),
solver
=
next
.
defer
();
Array
.
prototype
.
forEach
.
call
(
arguments
,
function
(
item
)
{
items
.
forEach
(
function
(
item
)
{
Promise
.
when
(
item
).
done
(
solver
.
resolve
).
fail
(
solver
.
reject
);
});
return
next
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment