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
32559fcb
Commit
32559fcb
authored
May 20, 2013
by
Domenic Denicola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make `RSVP.denodeify` pass along `thisArg`.
See discussion in #55.
parent
8c80ba5e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
1 deletion
+19
-1
lib/rsvp/node.js
lib/rsvp/node.js
+2
-1
tests/extension-tests.js
tests/extension-tests.js
+17
-0
No files found.
lib/rsvp/node.js
View file @
32559fcb
...
@@ -16,6 +16,7 @@ function makeNodeCallbackFor(resolve, reject) {
...
@@ -16,6 +16,7 @@ function makeNodeCallbackFor(resolve, reject) {
function
denodeify
(
nodeFunc
)
{
function
denodeify
(
nodeFunc
)
{
return
function
()
{
return
function
()
{
var
nodeArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
),
resolve
,
reject
;
var
nodeArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
),
resolve
,
reject
;
var
thisArg
=
this
;
var
promise
=
new
Promise
(
function
(
nodeResolve
,
nodeReject
)
{
var
promise
=
new
Promise
(
function
(
nodeResolve
,
nodeReject
)
{
resolve
=
nodeResolve
;
resolve
=
nodeResolve
;
...
@@ -26,7 +27,7 @@ function denodeify(nodeFunc) {
...
@@ -26,7 +27,7 @@ function denodeify(nodeFunc) {
nodeArgs
.
push
(
makeNodeCallbackFor
(
resolve
,
reject
));
nodeArgs
.
push
(
makeNodeCallbackFor
(
resolve
,
reject
));
try
{
try
{
nodeFunc
.
apply
(
this
,
nodeArgs
);
nodeFunc
.
apply
(
this
Arg
,
nodeArgs
);
}
catch
(
e
)
{
}
catch
(
e
)
{
reject
(
e
);
reject
(
e
);
}
}
...
...
tests/extension-tests.js
View file @
32559fcb
...
@@ -273,6 +273,23 @@ describe("RSVP extensions", function() {
...
@@ -273,6 +273,23 @@ describe("RSVP extensions", function() {
});
});
});
});
specify
(
'
calls node function with same thisArg
'
,
function
(
done
)
{
var
thisArg
=
null
;
function
nodeFunc
(
cb
)
{
thisArg
=
this
;
cb
();
}
var
denodeifiedFunc
=
RSVP
.
denodeify
(
nodeFunc
);
var
expectedThis
=
{
expect
:
"
me
"
};
denodeifiedFunc
.
call
(
expectedThis
).
then
(
function
()
{
assert
.
equal
(
thisArg
,
expectedThis
);
done
();
});
});
specify
(
'
waits for promise/thenable arguments to settle before passing them to the node function
'
,
function
(
done
)
{
specify
(
'
waits for promise/thenable arguments to settle before passing them to the node function
'
,
function
(
done
)
{
var
args
=
null
;
var
args
=
null
;
...
...
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