Skip to content

Commit

Permalink
fix(proxy): don't throw on missing property
Browse files Browse the repository at this point in the history
BREAKING CHANGE:

Given that simple access of a non-existent property on a JavaScript
object will return `undefined`, `promwrap` should follow suit.
  • Loading branch information
boneskull committed Jan 31, 2018
1 parent 9b7f6ca commit dacaec1
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ const handler = {
target.cache.set(name, val)
return val
}
throw new Error(`Module has no property named ${name}`)
}
}

Expand Down
18 changes: 11 additions & 7 deletions test/test-basics.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,16 @@ test('test basics', t => {
])
})

test('test error', t => {
test('unknown property', t => {
t.plan(2)
try {
console.log(promwrap(_module).notfound)
} catch (e) {
t.type(e, 'Error')
t.type(e.message, (`Module has no property named notfound`))
}
t.same(_module.foo, void 0)
let mod = promwrap(_module)
t.same(mod.foo, void 0)
})

test('unknown function', t => {
t.plan(2)
t.throws(() => _module.foo())
let mod = promwrap(_module)
t.throws(() => mod.foo())
})

0 comments on commit dacaec1

Please sign in to comment.