UNPKG

tiny-essentials

Version:

Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.

27 lines 1.23 kB
/** * Filters a list of strings by comparing each item against a list of validators. * * Each validator can be either: * - A **string** (for exact match) * - An **object** with one or more of the following: * - `starts`: {string} - The string must start with this prefix. * - `ends`: {string} - The string must end with this suffix. * - `regexp`: {RegExp} - The string must match the regular expression. * * The comparison stops at the first matching validator per item. * * Examples: * ```js * super_string_filter(['apple', 'banana', 'blueberry'], ['banana']); // ['banana'] * super_string_filter(['apple', 'banana'], [{ starts: 'app' }]); // ['apple'] * super_string_filter(['test.js'], [{ ends: '.js' }]); // ['test.js'] * super_string_filter(['data123'], [{ regexp: /^\w+\d+$/ }]); // ['data123'] * ``` * * @param {string[]} list - The list of strings to filter. * @param {(string|Object)[]} validator_list - The list of validators. * @returns {string[]} A filtered array of strings that passed at least one validator. * @deprecated */ export default function super_string_filter(list: string[], validator_list: (string | Object)[]): string[]; //# sourceMappingURL=super_string_filter.d.mts.map