Skip to content

Commit

Permalink
feat: Add "not" for negating a predicate
Browse files Browse the repository at this point in the history
  • Loading branch information
andreidmt committed Apr 7, 2020
1 parent 45f6750 commit 80fa470
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export { i } from "./i/i"
export { inc } from "./inc/inc"
export { indexBy } from "./index-by/index-by"
export { intersect } from "./intersect/intersect"
export { is, isNothing, isTrue, isFalse, isObject } from "./is/is"
export { is, isNothing, not, isTrue, isFalse, isObject } from "./is/is"
export { isEmpty, isNotEmpty } from "./is-empty/is-empty"
export { isMatch } from "./is-match/is-match"
export { join } from "./join/join"
Expand Down
4 changes: 3 additions & 1 deletion src/is/is.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,6 @@ const isTrue = source => source === true

const isFalse = source => source === false

export { is, isNothing, isTrue, isFalse, isObject }
const not = fn => source => !fn(source)

export { is, not, isNothing, isTrue, isFalse, isObject }
4 changes: 3 additions & 1 deletion src/is/is.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import test from "tape"
import { is, isNothing, isTrue, isFalse, isObject } from ".."
import { is, isNothing, isTrue, not, isFalse, isObject } from ".."

/**
* Test if something is not `null` or `undefined`
Expand Down Expand Up @@ -28,6 +28,8 @@ test("core::is", t => {
t.equal(is(undefined), false, 'Is "undefined" something')
t.equal(is(NaN), false, 'Is "NaN" something')

t.equal(not(is)(NaN), true, '"NaN" is not something')

t.equal(isTrue(""), false, "empty string is not true")
t.equal(isTrue(true), true, "boolean value true is true")

Expand Down

0 comments on commit 80fa470

Please sign in to comment.