tar
Version:
tar for JavaScript
20 lines • 772 B
JavaScript
/**
* A copy of the options with no prototype, so that an option that is
* not set cannot get a value from a changed `Object.prototype`.
*/
export const ownOptions = (opt, more) => Object.assign(Object.create(null), opt, more);
/**
* The value of an option that is a count, such as `jobs`: the
* default if the option is not set or is 0, and a `TypeError` if the
* value is not a positive integer or `Infinity`.
*/
export const countOption = (name, value, def) => {
if (value === undefined || value === null || value === 0)
return def;
if (value === Infinity ||
(Number.isInteger(value) && Number(value) > 0)) {
return value;
}
throw new TypeError(`${name} must be a positive integer`);
};
//# sourceMappingURL=options.js.map