summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/libnpx/util.js
blob: 2f3e4003aacebb32d4fc1dcd0f70a644fe0536bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'use strict'

module.exports.promisify = promisify
function promisify (f) {
  const util = require('util')
  if (util.promisify) {
    return util.promisify(f)
  } else {
    return function () {
      return new Promise((resolve, reject) => {
        f.apply(this, [].slice.call(arguments).concat((err, val) => {
          err ? reject(err) : resolve(val)
        }))
      })
    }
  }
}