Comparing version 5.0.0 to 6.0.0
{ | ||
"name": "gamla", | ||
"version": "5.0.0", | ||
"version": "6.0.0", | ||
"description": "functional programing for javascript", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
import { after, applyTo, before, identity, pipe } from "./composition.js"; | ||
import { head, second, unique, wrapArray } from "./array.js"; | ||
import { head, second, wrapArray } from "./array.js"; | ||
@@ -42,3 +42,12 @@ import { Map } from "immutable"; | ||
export const edgesToGraph = pipe(groupBy(head), map(pipe(map(second), unique))); | ||
export const edgesToGraph = pipe( | ||
groupByReduce( | ||
head, | ||
(s, edge) => { | ||
s.add(edge[1]); | ||
return s; | ||
}, | ||
() => new Set(), | ||
), | ||
); | ||
@@ -45,0 +54,0 @@ const onEntries = (transformation) => |
import { | ||
addEntry, | ||
applySpec, | ||
edgesToGraph, | ||
groupBy, | ||
@@ -108,1 +109,12 @@ index, | ||
}); | ||
test("edgesToGraph", () => { | ||
expect( | ||
edgesToGraph([ | ||
[1, 2], | ||
[1, 3], | ||
[4, 4], | ||
[2, 3], | ||
]), | ||
).toEqual({ 1: new Set([2, 3]), 2: new Set([3]), 4: new Set([4]) }); | ||
}); |
40582
1431