Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed identifier of bound functions on node 4 #9

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
node_js:
- "0.8"
- "0.10"
- "0.11"
- "4.1"
language: node_js
script: "npm run-script test-travis"
after_script: "npm install coveralls@2 && cat ./coverage/lcov.info | coveralls"
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = thenify

function thenify($$__fn__$$) {
assert(typeof $$__fn__$$ === 'function')
return eval(createWrapper($$__fn__$$.name))
return eval(createWrapper($$__fn__$$.name.replace(/\s|bound(?!$)/g,'')))
}

/**
Expand Down
8 changes: 8 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ it('fn.name', function () {
assert.equal('', thenify(noname).name)
})

it('fn.name (bound function)', function () {
function bound() {}
assert.equal('bound', thenify(bound).name)

var noname = (function () {}).bind(this)
assert.equal('', thenify(noname).name)
})

it('fn(callback(err))', function () {
function fn(cb) {
setTimeout(function () {
Expand Down