MCPcopy Create free account
hub / github.com/Effect-TS/effect / make

Function make

packages/effect/src/Graph.ts:502–521  ·  view source on GitHub ↗
(type: T)

Source from the content-addressed store, hash-verified

500 */
501export const make =
502 <T extends Kind>(type: T) => <N, E>(mutate?: (mutable: MutableGraph<N, E, T>) => undefined): Graph<N, E, T> => {
503 const graph: Mutable<GraphImpl<N, E, T>> = Object.create(ProtoGraph)
504 graph.type = type
505 graph.nodes = new Map()
506 graph.edges = new Map()
507 graph.adjacency = new Map()
508 graph.reverseAdjacency = new Map()
509 graph.nextNodeIndex = 0
510 graph.nextEdgeIndex = 0
511 graph.acyclic = Option.some(true)
512
513 if (mutate === undefined) {
514 graph.mutable = false
515 return graph as unknown as Graph<N, E, T>
516 }
517
518 graph.mutable = true
519 const mutable = Equal.byReferenceUnsafe(graph as unknown as MutableGraph<N, E, T>)
520 return mutateScoped(mutable, mutate)
521 }
522
523/**
524 * Creates a directed graph, optionally with initial mutations.

Callers 1

Graph.tsFile · 0.70

Calls 2

mutateScopedFunction · 0.85
someMethod · 0.80

Tested by

no test coverage detected