MCPcopy Create free account
hub / github.com/apache/cloudstack / promisify

Function promisify

systemvm/agent/noVNC/utils/convert.js:23–33  ·  view source on GitHub ↗
(original)

Source from the content-addressed store, hash-verified

21
22// util.promisify requires Node.js 8.x, so we have our own
23function promisify(original) {
24 return function promiseWrap() {
25 const args = Array.prototype.slice.call(arguments);
26 return new Promise((resolve, reject) => {
27 original.apply(this, args.concat((err, value) => {
28 if (err) return reject(err);
29 resolve(value);
30 }));
31 });
32 };
33}
34
35const writeFile = promisify(fs.writeFile);
36

Callers 1

convert.jsFile · 0.85

Calls 4

rejectFunction · 0.85
applyMethod · 0.65
resolveFunction · 0.50
callMethod · 0.45

Tested by

no test coverage detected