Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
rsvp.js
Commits
d54f9c2d
Commit
d54f9c2d
authored
May 28, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #83 from teddyzeenny/all-exception
Throw exception in all called without an array
parents
71f121c1
d8d19e41
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
+17
-0
lib/rsvp/all.js
lib/rsvp/all.js
+3
-0
tests/extension-tests.js
tests/extension-tests.js
+14
-0
No files found.
lib/rsvp/all.js
View file @
d54f9c2d
import
{
Promise
}
from
"
rsvp/promise
"
;
import
{
Promise
}
from
"
rsvp/promise
"
;
function
all
(
promises
)
{
function
all
(
promises
)
{
if
(
toString
.
call
(
promises
)
!==
"
[object Array]
"
)
{
throw
new
TypeError
(
'
You must pass an array to all.
'
);
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
results
=
[],
remaining
=
promises
.
length
,
var
results
=
[],
remaining
=
promises
.
length
,
promise
;
promise
;
...
...
tests/extension-tests.js
View file @
d54f9c2d
...
@@ -483,6 +483,20 @@ describe("RSVP extensions", function() {
...
@@ -483,6 +483,20 @@ describe("RSVP extensions", function() {
assert
(
RSVP
.
all
);
assert
(
RSVP
.
all
);
});
});
it
(
'
throws when not passed an array
'
,
function
()
{
assert
.
throws
(
function
()
{
var
all
=
RSVP
.
all
();
},
TypeError
);
assert
.
throws
(
function
()
{
var
all
=
RSVP
.
all
(
''
);
},
TypeError
);
assert
.
throws
(
function
()
{
var
all
=
RSVP
.
all
({});
},
TypeError
);
});
specify
(
'
fulfilled only after all of the other promises are fulfilled
'
,
function
(
done
)
{
specify
(
'
fulfilled only after all of the other promises are fulfilled
'
,
function
(
done
)
{
var
firstResolved
,
secondResolved
,
firstResolver
,
secondResolver
;
var
firstResolved
,
secondResolved
,
firstResolver
,
secondResolver
;
...
...
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