UNPKG

predictype

Version:

PredicType is a library of pre-built and tested predicates for TypeScript, covering various data types and operations.

26 lines (25 loc) 933 B
import { StringMembershipOper } from '../../enums/strings.js'; /** * Checks if a string is (or is not) a member of a set of strings using the specified operation. * * @param source The string to check. * @param oper The membership operation to perform (e.g. 'in', 'not_in'). * @param target The array of strings to check membership against. * @returns True if the membership check is valid according to the operator, otherwise false. * * @throws {Error} If the operation is not recognized. * * @example * const arr = ['foo', 'bar']; * const value1 = 'foo'; * const value2 = 'baz'; * * stringMembership(value1, 'in', arr); // true * stringMembership(value2, 'not_in', arr); // true * * @remarks * Supported Operators: * - **IN**: String is in the array * - **NOT_IN**: String is not in the array */ export declare function stringMembership(source: string, oper: StringMembershipOper, target: string[]): boolean;