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
00a9b910
Commit
00a9b910
authored
May 20, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #77 from domenic/denodeify-this-fix
Make `RSVP.denodeify` pass along `thisArg`.
parents
8c80ba5e
32559fcb
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 @
00a9b910
...
...
@@ -16,6 +16,7 @@ function makeNodeCallbackFor(resolve, reject) {
function
denodeify
(
nodeFunc
)
{
return
function
()
{
var
nodeArgs
=
Array
.
prototype
.
slice
.
call
(
arguments
),
resolve
,
reject
;
var
thisArg
=
this
;
var
promise
=
new
Promise
(
function
(
nodeResolve
,
nodeReject
)
{
resolve
=
nodeResolve
;
...
...
@@ -26,7 +27,7 @@ function denodeify(nodeFunc) {
nodeArgs
.
push
(
makeNodeCallbackFor
(
resolve
,
reject
));
try
{
nodeFunc
.
apply
(
this
,
nodeArgs
);
nodeFunc
.
apply
(
this
Arg
,
nodeArgs
);
}
catch
(
e
)
{
reject
(
e
);
}
...
...
tests/extension-tests.js
View file @
00a9b910
...
...
@@ -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
)
{
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