Permalink
Browse files

fix: Anonymous function name

Applying partial to an anonymous function twice no longer results in
'partial partial' as the function name.
  • Loading branch information...
mickvangelderen committed Dec 28, 2016
1 parent 578a283 commit d7acbfb3f70219d57f269c580475dab5695fd894
Showing with 4 additions and 1 deletion.
  1. +1 −1 partial.js
  2. +3 −0 partial.test.js
@@ -36,7 +36,7 @@ module.exports = function partial(func:Function, args:Array<any>):Function {
{
name: {
value: func.name
? /^partial /.test(func.name)
? /^partial( |$)/.test(func.name)
? func.name
: `partial ${func.name}`
: 'partial',
@@ -42,6 +42,9 @@ describe('partial', () => {
args: [ 12, 6 ]
})
expect(two()).to.equal(2)

expect(partial(function() {}, []).name).to.equal('partial')
expect(partial(partial(function () {}, []), []).name).to.equal('partial')
})

it('should take into account placeholders', () => {

0 comments on commit d7acbfb

Please sign in to comment.