Skip to content

Commit

Permalink
fix: Accept null inputs in curried functions
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvdm committed May 1, 2020
1 parent c279c9e commit 10a658f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
4 changes: 1 addition & 3 deletions join.js
@@ -1,9 +1,7 @@
var tuple = require('./tuple')

function join(a, b, c) {
return a != null && b != null && c == null
? joinCurried(a, b)
: joinMain(a, b, c)
return b != null && c == null ? joinCurried(a, b) : joinMain(a, b, c)
}

function joinMain(id, joiner, makerFns) {
Expand Down
1 change: 1 addition & 0 deletions tests/fictional.test.js
Expand Up @@ -54,6 +54,7 @@ tap.test('consistency', t => {
tap.test('curried makers', t => {
for (const [fn, ...args] of curriedMakerDefs) {
t.deepEquals(fn(23, ...args), fn(...args)(23))
t.deepEquals(fn(null, ...args), fn(...args)(null))
}

t.end()
Expand Down
2 changes: 1 addition & 1 deletion tuple.js
@@ -1,7 +1,7 @@
var hash = require('./hash')

function tuple(a, b) {
return a != null && b != null ? tupleMain(a, b) : tupleCurried(a)
return b != null ? tupleMain(a, b) : tupleCurried(a)
}

function tupleMain(input, fns) {
Expand Down

0 comments on commit 10a658f

Please sign in to comment.