MCPcopy
hub / github.com/brunch/brunch / promisify

Function promisify

lib/utils/plugin-adapter.js:55–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

53
54const bind = (fn, plugin) => fn.bind(plugin);
55const promisify = returnsFile => fn => {
56 switch (fn.length) {
57 case 1:
58 // Modern API:
59 return fn;
60 case 2:
61 // Legacy API:
62 return returnsFile ?
63 microPromisify(fn) : // fn(file, callback) => void
64 file => fn(file.data, file.path); // fn(data, path) => Promise
65 case 3:
66 // Legacy API: fn(data, path, callback) => void
67 const promisified = microPromisify(fn);
68 return file => promisified(file.data, file.path);
69 }
70};
71
72const thenify = fn => {
73 return file => Promise.resolve(file).then(fn);

Callers 7

launchServerFileModuleFunction · 0.85
init-skeleton.jsFile · 0.85
existsFunction · 0.85
helpers.jsFile · 0.85
normMethodsFunction · 0.85
config.jsFile · 0.85
generate.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…