Skip to content

Commit

Permalink
fix(transducers): flattenWith()
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 2, 2018
1 parent befaceb commit 3d8aa32
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/transducers/src/xform/flatten-with.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ export function flattenWith<T>(fn: (x: T) => Iterable<T>): Transducer<T | Iterab
return (rfn: Reducer<any, T>) => {
const r = rfn[2];
const flatten = (acc, x) => {
x = fn(x);
if (x) {
for (let y of x) {
const xx = fn(x);
if (xx) {
for (let y of xx) {
acc = flatten(acc, y);
if (isReduced(acc)) {
break;
Expand All @@ -18,6 +18,6 @@ export function flattenWith<T>(fn: (x: T) => Iterable<T>): Transducer<T | Iterab
}
return r(acc, x);
};
return compR(rfn, fn);
return compR(rfn, flatten);
};
}

0 comments on commit 3d8aa32

Please sign in to comment.