UNPKG

@jil/args

Version:

A convention based argument parsing and formatting library, with strict validation checks

18 lines 637 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.formatValue = void 0; const errors_1 = require("../errors"); function formatValue(value, format) { let nextValue = value; const prevType = typeof nextValue; if (typeof format === 'function' && prevType !== 'boolean') { nextValue = format(nextValue); const nextType = typeof nextValue; if (nextType !== prevType) { throw new errors_1.ArgsError('VALUE_INVALID_FORMAT', [prevType, nextType]); } } return nextValue; } exports.formatValue = formatValue; //# sourceMappingURL=formatValue.js.map