UNPKG

roc

Version:

Build modern web applications easily

36 lines (31 loc) 943 B
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = convert; /** * Given an input is a converter, it will return a converted result. * * @param {...function} converters - This is the converters. * * @returns {object} - The converted result. */ function convert() { for (var _len = arguments.length, converters = Array(_len), _key = 0; _key < _len; _key++) { converters[_key] = arguments[_key]; } if (!converters.length) { throw new Error('You need to use at least one converter.'); } return (input, defaultValue, name) => { for (let converter of converters) { const res = converter(input, defaultValue, name); // toBoolean will return false as a valid value if (!res && res !== false) { continue; } return res; } }; } //# sourceMappingURL=convert.js.map