type Proc = (data: any) => Promise | T; type Case = [...patterns: [any, ...Array], proc: Proc]; type ProcSync = (data: any) => T; type CaseSync = [...patterns: [any, ...Array], proc: ProcSync]; /** * Poor man's pattern matching in JS * Use it like a switch-case that is capable of doing deep equality * Unlike switch-case, it cannot assert the data type in the procedure * Without a default case, the returned value is undefined */ declare function match(data: any): (...cases: readonly [...Array>, Proc] | readonly [...Array>]) => Promise; /** * Poor man's pattern matching in JS * Use it like a switch-case that is capable of doing deep equality * Unlike switch-case, it cannot assert the data type in the procedure * Without a default case, the returned value is undefined * Synchronous version */ declare function matchSync(data: any): (...cases: readonly [...Array>, ProcSync] | readonly [...Array>]) => T; export { match, matchSync };