Skip to content

Commit

Permalink
feat(join): Support join()
Browse files Browse the repository at this point in the history
  • Loading branch information
justinvdm committed Apr 29, 2020
1 parent 1e1c598 commit 6ce20c6
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 12 deletions.
1 change: 1 addition & 0 deletions index.js
@@ -1,6 +1,7 @@
exports.hash = require('./hash')
exports.oneOf = require('./oneOf')
exports.tuple = require('./tuple')
exports.join = require('./join')

exports.int = require('./int')
exports.float = require('./float')
Expand Down
1 change: 1 addition & 0 deletions index.mjs
@@ -1,6 +1,7 @@
export { default as hash } from './has'
export { default as oneOf } from './oneOf'
export { default as tuple } from './tuple'
export { default as join } from './join'

export { default as int } from './int'
export { default as float } from './float'
Expand Down
19 changes: 19 additions & 0 deletions join.js
@@ -0,0 +1,19 @@
var tuple = require('./tuple')

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

function joinMain(id, joinerFn, makerFns) {
return joinerFn(tuple(id, makerFns))
}

function joinCurried(joinerFn, makerFns) {
return function joinFn(id) {
return joinMain(id, joinerFn, makerFns)
}
}

module.exports = join

0 comments on commit 6ce20c6

Please sign in to comment.