UNPKG

util-ex

Version:

Browser-friendly enhanced util fully compatible with standard node.js

16 lines (15 loc) 796 B
/** * Checks if a string matches any item in a list of strings or regular expressions. * @param {string} str - The string to match against the list. * @param {Array<string|RegExp>} list - The list of strings or regular expressions to match against. * @param {boolean=} caseSensitive - Whether the comparison should be case sensitive. Default is false. * @returns {boolean} - True if there is a match, false otherwise. * * @example * const list = ['apple', 'banana', 'orange']; * const str = 'Banana'; * console.log(isInList(str, list)); // true (no caseSensitive) * console.log(isInList(str, list, true)); // false (caseSensitive) */ export function isInList(str: string, list: Array<string | RegExp>, caseSensitive?: boolean | undefined): boolean; export default isInList;