Skip to content
Open
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: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ module.exports = function hookable(fn) {
return fn.apply(this, [].slice.call(arguments))
}

Object.assign(hooked, fn)

hooked.hook = function (hook) {
fn = wrap(fn, hook)
return this
Expand Down
21 changes: 21 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,24 @@ tape('check a thing, maybe return something different, else change result', func
t.end()

})

tape('preserve own properties', function (t) {

var add = function (a, b) {
return a + b
};

add.operation = 'addition'
add.obj = {}
add.hook = null

var h = Hoox(add)

t.equal(h(2, 4), 6)
t.equal(h.operation, 'addition')
t.deepEqual(h.obj, {})
t.ok(typeof h.hook === 'function')

t.end()

})