UNPKG

@comyata/run

Version:

Simplify data workflows and management with data templates, for browser and server.

39 lines (36 loc) 962 B
/** * @todo add fileId as global root identifier */ export class DataNode { engine = undefined; computed = undefined; // todo: this is mixing "data type" and "internal node type", not needed anymore? constructor(parent, path, valueType, value, extractExpr) { this.path = path; this.valueType = valueType; this.value = value; this.extractExpr = extractExpr; if (parent) { this.parent = () => parent; } } withHydrate(hydrate) { if (this.hydrate) { throw new Error(`Can not overwrite hydrate in ${JSON.stringify(this.path)}`); } this.hydrate = hydrate; return this; } } export class DataNodeObject extends DataNode { children = new Map(); constructor(parent, path, valueType, value) { super(parent, path, valueType, value); } append(key, dataNode) { this.children.set(key, dataNode); } } export function isComputedNode(node) { return Boolean(node.engine && node.computed); }