Skip to content

Commit

Permalink
fix: correct binding of overwritten functions
Browse files Browse the repository at this point in the history
there was 1 closure missing, everything was broken 😞
  • Loading branch information
eins78 committed Oct 23, 2015
1 parent e986f0f commit dad6f47
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/lib/callWithNewObject.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
export default (fun, ...args) => {
return fun.bind(undefined, Object.create(null), ...args)
export default (func) => {
return function () {
return func.bind(undefined, Object.create(null)).apply(undefined, arguments)
}
}
5 changes: 4 additions & 1 deletion test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test('activeLodash', (t) => {
})

t.test('merge', (t) => {
t.plan(2)
t.plan(3)

t.looseEqual(
f.merge(
Expand All @@ -64,6 +64,9 @@ test('activeLodash', (t) => {
let o = {s: 3}
f.merge(o, {b: 2})
t.deepEqual(o, {s: 3}, 'does not mutate the arguments')

// test for stupidity – makes sure it works more than 1 time 😕
t.deepEqual(f.merge({b: 2}, {c: 3}), {b: 2, c: 3}, 'does bind correctly')
})

t.test('presence', (assert) => {
Expand Down

0 comments on commit dad6f47

Please sign in to comment.