UNPKG

@technobuddha/library

Version:
45 lines (44 loc) 1.68 kB
"use strict"; var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.matches = void 0; var isRegExp_1 = __importDefault(require("lodash/isRegExp")); var isString_1 = __importDefault(require("lodash/isString")); function matches(text, match) { var e_1, _a; text = text.trim().toLowerCase(); if (isRegExp_1.default(match)) return match.test(text); if (isString_1.default(match)) return match.toLowerCase() === text; try { for (var match_1 = __values(match), match_1_1 = match_1.next(); !match_1_1.done; match_1_1 = match_1.next()) { var m = match_1_1.value; if ((isRegExp_1.default(m) && m.test(text)) || (isString_1.default(m) && m.toLowerCase() === text)) return true; } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (match_1_1 && !match_1_1.done && (_a = match_1.return)) _a.call(match_1); } finally { if (e_1) throw e_1.error; } } return false; } exports.matches = matches; exports.default = matches;