diff --git a/.github/README.md b/.github/README.md index c57ec737..863b13fe 100644 --- a/.github/README.md +++ b/.github/README.md @@ -4150,6 +4150,8 @@ function parseRegex(maybeRegex){ export function equals(a, b){ if (arguments.length === 1) return _b => equals(a, _b) + if (Object.is(a, b)) return true + const aType = type(a) if (aType !== type(b)) return false @@ -4554,7 +4556,7 @@ describe('brute force', () => { { "ERRORS_MESSAGE_MISMATCH": 0, "ERRORS_TYPE_MISMATCH": 0, - "RESULTS_MISMATCH": 8, + "RESULTS_MISMATCH": 0, "SHOULD_NOT_THROW": 0, "SHOULD_THROW": 0, "TOTAL_TESTS": 289, diff --git a/README.md b/README.md index f8c04d5e..617e47dd 100644 --- a/README.md +++ b/README.md @@ -3925,6 +3925,8 @@ function parseRegex(maybeRegex){ export function equals(a, b){ if (arguments.length === 1) return _b => equals(a, _b) + if (Object.is(a, b)) return true + const aType = type(a) if (aType !== type(b)) return false @@ -4329,7 +4331,7 @@ describe('brute force', () => { { "ERRORS_MESSAGE_MISMATCH": 0, "ERRORS_TYPE_MISMATCH": 0, - "RESULTS_MISMATCH": 8, + "RESULTS_MISMATCH": 0, "SHOULD_NOT_THROW": 0, "SHOULD_THROW": 0, "TOTAL_TESTS": 289, diff --git a/src/unless.js b/src/unless.js index 0b381ac8..22cc648d 100644 --- a/src/unless.js +++ b/src/unless.js @@ -1,11 +1,7 @@ -import { curry } from './curry.js' +export function unless(predicate, whenFalse){ + if (arguments.length === 1){ + return _whenFalse => unless(predicate, _whenFalse) + } -function unlessFn( - predicate, whenFalseFn, input -){ - if (predicate(input)) return input - - return whenFalseFn(input) + return input => predicate(input) ? input : whenFalse(input) } - -export const unless = curry(unlessFn) \ No newline at end of file