Created
June 23, 2017 19:25
-
-
Save dunstontc/8328efc091835222bcf63778bac88158 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
module.exports = (fn) => { | |
return function () { | |
const length = arguments.length; | |
const args = new Array(length); | |
for (let i = 0; i < length; i += 1) { | |
args[i] = arguments[i]; | |
} | |
return new Promise((resolve, reject) => { | |
args.push((err, data) => { | |
if (err) { | |
reject(err); | |
} else { | |
resolve(data); | |
} | |
}); | |
fn.apply(null, args); | |
}); | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment