graph-ecs/tests/utils.js

14 lines
518 B
JavaScript
Raw Normal View History

2024-11-14 00:32:46 +01:00
import { KeyValuePair, Name, Label, Identifier, Literal, Edge, Node } from '../src/query/types.js'
2024-11-13 20:24:29 +01:00
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)),
2024-11-14 00:32:46 +01:00
props.map(keyValuePair)
2024-11-13 20:24:29 +01:00
)
export const makeNode = graphObject
export const makeEdge = (name, label, props) => graphObject(name, label, props, Edge)