1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 2x 4x 4x 1x 1x | function toArray(a) { return Array.isArray(a) ? a : [a]; } const isPromise = v => v && v.then; const toPromise = v => (isPromise(v) ? v : Promise.resolve(v)); const delay = typeof setImmediate === undefined ? fn => setTimeout(fn, 0) : setImmediate; module.exports = { toArray, toPromise, delay }; |