Skip to content

Commit

Permalink
fix(transducers): revert mean() from regression introduced in 095e6ef
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Jul 9, 2018
1 parent 5ec6140 commit 03543ee
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/transducers/src/rfn/mean.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Reducer } from "../api";
import { reducer } from "../reduce";

export function mean(): Reducer<number, number> {
let n = 0;
return reducer(() => 0, (acc, x) => (n++ , acc + x));
return [
() => 0,
(acc) => acc / n,
(acc, x) => (n++ , acc + x),
];
}

0 comments on commit 03543ee

Please sign in to comment.