@plugjs/plug
Version:
PlugJS Build System ===================
17 lines • 604 B
JavaScript
/**
* 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