util.js 436 B

12345678910111213
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. exports.promisify = void 0;
  4. function promisify(fs, fn, getResult = input => input) {
  5. return (...args) => new Promise((resolve, reject) => {
  6. fs[fn].bind(fs)(...args, (error, result) => {
  7. if (error)
  8. return reject(error);
  9. return resolve(getResult(result));
  10. });
  11. });
  12. }
  13. exports.promisify = promisify;