Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function callback2promise(func) {
- return function () {
- var args = [].slice.call(arguments);
- return new Promise((resolve, reject) => {
- args.push((error, data) => {
- if (error) {
- reject(error);
- } else {
- resolve(data);
- }
- });
- func.apply(null, args);
- });
- };
- }
- module.exports = callback2promise;
Add Comment
Please, Sign In to add comment