| 53 | |
| 54 | const bind = (fn, plugin) => fn.bind(plugin); |
| 55 | const 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 | |
| 72 | const thenify = fn => { |
| 73 | return file => Promise.resolve(file).then(fn); |
no outgoing calls
no test coverage detected
searching dependent graphs…