Skip to content

Commit

Permalink
fix(transducers): update normFrequenciesAuto()
Browse files Browse the repository at this point in the history
- actually use `key` fn arg (if given)
  • Loading branch information
postspectacular committed Aug 19, 2021
1 parent 2c2f921 commit 5b5200b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/transducers/src/rfn/norm-frequencies-auto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { frequencies } from "./frequencies";
*
* normFrequenciesAuto(items)
* // Map(5) { 1 => 0.4, 2 => 0.3, 3 => 0.1, 4 => 0.1, 5 => 0.1 }
*
* // frequencies by 1st letter
* normFrequenciesAuto(x => x[0], ["alice", "abba", "bob", "charlie"])
* // Map(3) { 'a' => 0.5, 'b' => 0.25, 'c' => 0.25 }
* ```
*/
export function normFrequenciesAuto<A>(): Reducer<Map<A, number>, A>;
Expand All @@ -29,7 +33,7 @@ export function normFrequenciesAuto(...args: any[]): any {
if (res !== undefined) {
return res;
}
const [init, complete, reduce] = frequencies();
const [init, complete, reduce] = frequencies(...(<[]>args));
let norm = 0;
return [
init,
Expand Down

0 comments on commit 5b5200b

Please sign in to comment.