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
Boris Kocherov
rsvp.js
Commits
59a869e9
Commit
59a869e9
authored
Aug 25, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #103 from twokul/RSVP#rethrow
Rsvp#rethrow
parents
7f6b2674
2e98c2d0
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
5 deletions
+59
-5
lib/rsvp.js
lib/rsvp.js
+2
-1
lib/rsvp/async.js
lib/rsvp/async.js
+1
-1
lib/rsvp/rethrow.js
lib/rsvp/rethrow.js
+10
-0
test/index.html
test/index.html
+3
-3
test/tests/extension_test.js
test/tests/extension_test.js
+43
-0
No files found.
lib/rsvp.js
View file @
59a869e9
...
...
@@ -3,6 +3,7 @@ import { Promise } from "./rsvp/promise";
import
{
denodeify
}
from
"
./rsvp/node
"
;
import
{
all
}
from
"
./rsvp/all
"
;
import
{
hash
}
from
"
./rsvp/hash
"
;
import
{
rethrow
}
from
"
./rsvp/rethrow
"
;
import
{
defer
}
from
"
./rsvp/defer
"
;
import
{
config
}
from
"
./rsvp/config
"
;
import
{
resolve
}
from
"
./rsvp/resolve
"
;
...
...
@@ -12,4 +13,4 @@ function configure(name, value) {
config
[
name
]
=
value
;
}
export
{
Promise
,
EventTarget
,
all
,
hash
,
defer
,
denodeify
,
configure
,
resolve
,
reject
};
export
{
Promise
,
EventTarget
,
all
,
hash
,
rethrow
,
defer
,
denodeify
,
configure
,
resolve
,
reject
};
lib/rsvp/async.js
View file @
59a869e9
...
...
@@ -51,7 +51,7 @@ function useMutationObserver() {
function
useSetTimeout
()
{
return
function
(
callback
,
arg
)
{
setTimeout
(
function
()
{
global
.
setTimeout
(
function
()
{
callback
(
arg
);
},
1
);
};
...
...
lib/rsvp/rethrow.js
0 → 100644
View file @
59a869e9
var
local
=
(
typeof
global
===
"
undefined
"
)
?
this
:
global
;
function
rethrow
(
reason
)
{
local
.
setTimeout
(
function
()
{
throw
reason
;
});
throw
reason
;
}
export
{
rethrow
};
test/index.html
View file @
59a869e9
...
...
@@ -6,15 +6,15 @@
</head>
<body>
<div
id=
"mocha"
></div>
<script
src=
"../dist/rsvp-2.0.
0
.js"
></script>
<script
src=
"../dist/rsvp-2.0.
1
.js"
></script>
<script
src=
"vendor/assert.js"
></script>
<script
src=
"vendor/mocha.js"
></script>
<script>
mocha
.
setup
({
ui
:
'
bdd
'
,
timeout
:
200
})
</script>
<script>
mocha
.
setup
({
ui
:
'
bdd
'
,
timeout
:
200
})
;
mocha
.
globals
([
'
setTimeout
'
]);
</script>
<script
src=
"../tmp/tests-bundle.js"
></script>
<script
src=
"tests/extension_test.js"
></script>
<script>
if
(
window
.
mochaPhantomJS
)
{
mochaPhantomJS
.
run
();
}
else
{
mocha
.
run
();
}
else
{
mocha
.
globals
([
'
setTimeout
'
]);
mocha
.
run
();
}
</script>
</body>
</html>
test/tests/extension_test.js
View file @
59a869e9
/*global describe, specify, it, assert */
var
local
=
(
typeof
global
===
"
undefined
"
)
?
this
:
global
;
if
(
typeof
Object
.
getPrototypeOf
!==
"
function
"
)
{
Object
.
getPrototypeOf
=
""
.
__proto__
===
String
.
prototype
?
function
(
object
)
{
...
...
@@ -724,6 +726,47 @@ describe("RSVP extensions", function() {
});
});
describe
(
"
RSVP.rethrow
"
,
function
()
{
var
onerror
,
oldSetTimeout
=
global
.
setTimeout
;
after
(
function
()
{
global
.
setTimeout
=
oldSetTimeout
;
});
it
(
"
should exist
"
,
function
()
{
assert
(
RSVP
.
rethrow
);
});
it
(
"
rethrows an error
"
,
function
(
done
)
{
var
thrownError
=
new
Error
(
'
I am an error.
'
);
local
.
setTimeout
=
function
(
callback
)
{
done
();
var
errorWasThrown
=
false
;
try
{
callback
.
call
(
this
,
arguments
);
}
catch
(
e
)
{
errorWasThrown
=
true
;
}
assert
(
errorWasThrown
,
'
expect that an error was thrown
'
);
};
function
expectRejection
(
reason
)
{
assertEqual
(
reason
,
thrownError
);
}
function
doNotExpectFulfillment
(
value
)
{
done
();
assert
(
false
,
value
);
}
RSVP
.
reject
(
thrownError
).
fail
(
RSVP
.
rethrow
).
then
(
doNotExpectFulfillment
,
expectRejection
);
});
});
describe
(
"
RSVP.resolve
"
,
function
(){
specify
(
"
it should exist
"
,
function
(){
assert
(
RSVP
.
resolve
);
...
...
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