• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 'use strict'
2 
3 module.exports.promisify = promisify
4 function promisify (f) {
5   const util = require('util')
6   if (util.promisify) {
7     return util.promisify(f)
8   } else {
9     return function () {
10       return new Promise((resolve, reject) => {
11         f.apply(this, [].slice.call(arguments).concat((err, val) => {
12           err ? reject(err) : resolve(val)
13         }))
14       })
15     }
16   }
17 }
18