From 18a0f8656b3bfc4c7894fc30acb207a7a7b8a14e Mon Sep 17 00:00:00 2001 From: kitsunecafe Date: Wed, 20 Nov 2024 14:59:03 -0600 Subject: [PATCH] remove old parser --- src/query-old.js | 49 ------------------------------------------------ 1 file changed, 49 deletions(-) delete mode 100644 src/query-old.js diff --git a/src/query-old.js b/src/query-old.js deleted file mode 100644 index 0c6eb9d..0000000 --- a/src/query-old.js +++ /dev/null @@ -1,49 +0,0 @@ -import { defineQuery, hasComponent } from 'bitecs' -/// danm this rules !!! -const re = /\((?\w+)?:(?\w+)\)(-\[(?\w+)?:(?\w+)\]->\((?\w+)?:(?\w+)\))*/ - -const node = (name, label) => ({ name, label }) - -const parse = s => { - const result = s.match(re) - const groups = result.groups - - return { - from: node(groups.fromName || 'a', groups.fromLabel), - to: node(groups.toName || 'b', groups.toLabel), - edge: node(groups.edgeName, groups.edgeLabel) - } -} - -export const query = (world, s) => { - const meta = parse(s) - const from = world.components[meta.from.label] - const to = world.components[meta.to.label] - const edge = world.components[meta.edge.label] - - const fromQuery = defineQuery([from]) - const toQuery = defineQuery([to]) - const edgeQuery = defineQuery([edge]) - - return (world) => { - const result = [] - - const fq = fromQuery(world) - const tq = toQuery(world) - const eq = edgeQuery(world) - - for(const feid of fq) { - const targets = [] - - for(const eeid of eq) { - if(edge.from[eeid] === feid && hasComponent(world, to, edge.to[eeid])) { - targets.push(edge.to[eeid]) - } - } - - result.push({ [feid]: targets }) - } - - return result - } -}