Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aurel
jio
Commits
71c385e0
Commit
71c385e0
authored
Aug 23, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Promise first updated
parent
b074cf52
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 @
71c385e0
...
...
@@ -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