Sha256: 37ee564b564e2745908fc8117388a1ea23dadba4c6345cd4b309532c16486984
Contents?: true
Size: 734 Bytes
Versions: 10
Compression:
Stored size: 734 Bytes
Contents
import { basename, dirname, extname, sep } from 'path'; import { makeLegalIdentifier } from 'rollup-pluginutils'; export function getName(id) { const name = makeLegalIdentifier(basename(id, extname(id))); if (name !== 'index') { return name; } else { const segments = dirname(id).split(sep); return makeLegalIdentifier(segments[segments.length - 1]); } } // Return the first non-falsy result from an array of // maybe-sync, maybe-promise-returning functions export function first(candidates) { return function(...args) { return candidates.reduce((promise, candidate) => { return promise.then(result => result != null ? result : Promise.resolve(candidate.call(this, ...args)) ); }, Promise.resolve()); }; }
Version data entries
10 entries across 10 versions & 1 rubygems