UNPKG

@plugjs/plug

Version:
17 lines 604 B
/** * Parse an array of arguments (a number of strings optionally followed by an * options object into parameters and options. */ export function parseOptions(args, defaults) { const params = []; const clone = [...args]; // Collect all strings at the beginning of our arguments array while (typeof clone[0] === 'string') { params.push(clone.shift()); } // The options is the _last_ element in our arguments array (if any) const options = Object.assign({}, defaults, clone.pop()); // All done return { params, options }; } //# sourceMappingURL=options.js.map