From cab0cf243db698539654985876ac41dce739eb15 Mon Sep 17 00:00:00 2001 From: kitsunecafe Date: Fri, 22 Nov 2024 15:47:02 -0600 Subject: [PATCH] fix assocPath --- src/fn.js | 2 +- src/query.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/fn.js b/src/fn.js index dd9128b..982262f 100644 --- a/src/fn.js +++ b/src/fn.js @@ -105,7 +105,7 @@ export const assocPath = curry((key, value, obj) => pipe( makePath, rev, reduce((acc, val) => ({ [val]: acc }), value), - mergeRightDeep(obj), + mergeLeftDeep(obj), )(key)) export const mergeRightDeep = curry((a, b) => diff --git a/src/query.js b/src/query.js index d798bc5..79799a0 100644 --- a/src/query.js +++ b/src/query.js @@ -1,7 +1,7 @@ import { defineQuery, hasComponent } from 'bitecs' import { query as q } from './query-parser/index.js' import { parseAll } from './parser.js' -import { curry, of, is, reduce, flip, concat, map, when, assoc, mergeLeft, isNil, path, prop, ifElse, diverge, pipe, always, assocPath, prepend, orDefault, useWith, applyTo } from './fn.js' +import { curry, of, is, reduce, flip, concat, map, when, assoc, mergeLeft, isNil, path, prop, ifElse, diverge, pipe, always, assocPath, prepend, orDefault, useWith, applyTo, tap } from './fn.js' import { Relationship } from './query-parser/types.js' const prepareQuery = (query, component) => { @@ -51,7 +51,7 @@ const queryRelationship = (from, edge, to, world) => { return result } -const assembleQuery = (query, entities) => map(entity => of({ entity, query }), entities) +const assembleQuery = curry((query, entities) => map(entity => of({ entity, query }), entities)) const executeQuery = curry((query, world) => { if (!query.relationship) { @@ -60,6 +60,7 @@ const executeQuery = curry((query, world) => { const { from, to: _to, edge } = query const to = when(prop('relationship'), prop('from'), _to) + const edges = queryRelationship( { type: from.type, results: from.query(world) }, { type: edge.type, results: edge.query(world) },