Last active
February 22, 2024 10:05
-
-
Save fResult/a6998e0e5d41283cd8d84da2c98f52ee to your computer and use it in GitHub Desktop.
Make meme for the `is-odd` module
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
// Usage: | |
import isEven from "is-not-odd"; | |
isEven(3); // false | |
isEven(4); // true | |
// In index.ts of `is-not-odd` module | |
import isOdd from "is-odd"; | |
type PredicateFn<T> = (...args: [T, ...any[]]) => boolean; | |
function not<T = any>(predicate: PredicateFn<T>): Parameters<typeof predicate> { | |
return function negate(...args) { | |
return !predicate(...args); | |
}; | |
} | |
const isEven = not(isOdd); | |
export default isEven; |
Author
fResult
commented
Feb 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment