Created
December 22, 2021 04:47
-
-
Save obaranovskyi/71e9ce60282107bacce01a72e0a3ad5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type PredicateFn = (value: any, index?: number) => boolean; | |
type ProjectionFn = (value: any, index?: number) => any; | |
function or(...predicates: PredicateFn[]): PredicateFn { | |
return (value) => predicates.some((predicate) => predicate(value)); | |
} | |
function and(...predicates: PredicateFn[]): PredicateFn { | |
return (value) => predicates.every((predicate) => predicate(value)); | |
} | |
function not(...predicates: PredicateFn[]): PredicateFn { | |
return (value) => predicates.every((predicate) => !predicate(value)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment