import { IdentityMatcher, ObjectMatcher, PatternMatcher, StringMatcher } from './pattern-matching/index.js'; import { ConstructorAbstractOrInstance } from './types/index.js'; // boolean equality matcher export function match(_: boolean): { when: ( pattern: boolean, transformation: (_: boolean) => Output_Type, ) => PatternMatcher, }; // number equality matcher export function match(_: number): { when: ( pattern: number, transformation: (_: number) => Output_Type, ) => PatternMatcher, }; // symbol equality matcher export function match(_: symbol): { when: ( pattern: symbol, transformation: (_: symbol) => Output_Type, ) => PatternMatcher, }; // string equality and regexp matcher export function match(_: string): { when: ( pattern: string | RegExp, transformation: (_: string) => Output_Type, ) => PatternMatcher, }; // type matcher export function match(_: Input_Type): { when: ( pattern: ConstructorAbstractOrInstance, transformation: (v: MT) => Output_Type, ) => PatternMatcher, Input_Type, Output_Type>, }; /** * @experimental * * @param value * @returns {PatternMatcher} */ export function match(value: any): PatternMatcher { // eslint-disable-line @typescript-eslint/explicit-module-boundary-types switch (true) { case typeof value === 'string': return new StringMatcher(value as string); case typeof value === 'object': return new ObjectMatcher(value); default: return new IdentityMatcher(value); } }