Skip to content

Commit f80c7d5

Browse files
author
tunnckoCore
committed
fix(opts): fix passing options when want thunk
1 parent 27c8e60 commit f80c7d5

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ module.exports = function tryCatchCallback (fn, cb, opts) {
4747
}
4848
if (typeof cb !== 'function') {
4949
return function thunk (done) {
50-
tryCatch.call(this, fn, done, opts)
50+
tryCatch.call(this, fn, done, cb || opts)
5151
}
5252
}
5353
tryCatch.call(this, fn, cb, opts)

test.js

+9
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,12 @@ test('should pass custom context using `tryCatch.call`', function (done) {
101101
test.strictEqual(this.qux, true)
102102
}, done)
103103
})
104+
105+
test('should allow passing options when want thunk', function (done) {
106+
var thunk = tryCatch(function () {
107+
test.strictEqual(this.a, 'b')
108+
}, { context: { a: 'b' } })
109+
110+
test.strictEqual(typeof thunk, 'function')
111+
thunk(done)
112+
})

0 commit comments

Comments
 (0)