Skip to content

Commit

Permalink
avoiding the use of reduce within the groupoid
Browse files Browse the repository at this point in the history
  • Loading branch information
sadasant committed Mar 20, 2017
1 parent a1f9ff2 commit 1c7cb2f
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,11 @@ export const groupoid = (...funs) => function G (
fN++
}
// if breadth first, going recursive on what was nested in this layer
if (nextBreadth.length) {
accepted = [accepted].concat(nextBreadth).reduce((a, { val, key }) => {
let result = G(val, a, breadth, orientation, path.concat(key))
if (result === true) return a
return result
})
let result = accepted
while (result && nextBreadth.length) {
let { val, key } = nextBreadth.shift()
result = G(val, accepted, breadth, orientation, path.concat(key))
if (result && result !== true) accepted = result
}
return accepted
}
Expand Down

0 comments on commit 1c7cb2f

Please sign in to comment.