UNPKG

@technobuddha/library

Version:
28 lines (27 loc) 932 B
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.toEnumeration = void 0; var matches_1 = __importDefault(require("../matches")); /** * Convert a string to a numeric value * * @param input The string to convert * @param tests Array of tests (string value or regular expressions) * @parm __namedParameters see {@link Options} * @returns The index of the first test to match the input string */ function toEnumeration(input) { var tests = []; for (var _i = 1; _i < arguments.length; _i++) { tests[_i - 1] = arguments[_i]; } for (var i = 0; i < tests.length; ++i) if (matches_1.default(input, tests[i])) return i; return undefined; } exports.toEnumeration = toEnumeration; exports.default = toEnumeration;