parent
8a9d0073b1
commit
7de58c8709
@ -1,9 +1,10 @@ |
|||||||
const promiseToCallback = require('promise-to-callback') |
const promiseToCallback = require('promise-to-callback') |
||||||
|
|
||||||
module.exports = function(fn, context) { |
module.exports = function nodeify (fn, context) { |
||||||
return function(){ |
return function(){ |
||||||
const args = [].slice.call(arguments) |
const args = [].slice.call(arguments) |
||||||
const callback = args.pop() |
const callback = args.pop() |
||||||
|
if (typeof callback !== 'function') throw new Error('callback is not a function') |
||||||
promiseToCallback(fn.apply(context, args))(callback) |
promiseToCallback(fn.apply(context, args))(callback) |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue