graph-ecs/tests/utils.js
2024-11-13 13:24:29 -06:00

13 lines
507 B
JavaScript

import { KeyValuePair, Name, Label, Identifier, Literal, Edge } from '../src/query/types.js'
export const keyValuePair = ([k, v]) => new KeyValuePair(new Name(new Identifier(k)), new Literal(v))
export const graphObject = (name, label, props = [], Type = Node) => new Type(
name && new Name(new Identifier(name)),
new Label(new Identifier(label)),
props.map(makeKvp)
)
export const makeNode = graphObject
export const makeEdge = (name, label, props) => graphObject(name, label, props, Edge)