@graffy/link 0.16.10-alpha.1 → 0.16.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +8 -10
- package/index.mjs +8 -10
- package/package.json +2 -2
package/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
const common = require("@graffy/common");
|
|
3
3
|
const debug = require("debug");
|
|
4
4
|
function linkGraph(rootGraph, defs) {
|
|
5
|
-
|
|
5
|
+
const version = rootGraph[0].version;
|
|
6
6
|
for (const { path, def } of defs) {
|
|
7
7
|
const braid = def.map(getChoices);
|
|
8
8
|
const strands = unbraid(braid);
|
|
@@ -74,7 +74,7 @@ function linkGraph(rootGraph, defs) {
|
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
const encodedKey = common.encodeArgs(key).key;
|
|
77
|
-
|
|
77
|
+
const node = graph[common.findFirst(graph, encodedKey)];
|
|
78
78
|
if (!node || common.cmp(node.key, encodedKey) !== 0 || node.end)
|
|
79
79
|
return [];
|
|
80
80
|
return recurse(node, rest, vars);
|
|
@@ -163,9 +163,8 @@ function prepQueryLinks(rootQuery, defs) {
|
|
|
163
163
|
)
|
|
164
164
|
};
|
|
165
165
|
});
|
|
166
|
-
} else {
|
|
167
|
-
return [{ path, def: prepareDef(def, vars) }];
|
|
168
166
|
}
|
|
167
|
+
return [{ path, def: prepareDef(def, vars) }];
|
|
169
168
|
}
|
|
170
169
|
function prefixKey(defs2, key2) {
|
|
171
170
|
return defs2.map(({ path: path2, def: def2 }) => ({
|
|
@@ -183,13 +182,12 @@ function prepQueryLinks(rootQuery, defs) {
|
|
|
183
182
|
vars[key.slice(1)] = common.decodeArgs(node);
|
|
184
183
|
return addDefQuery(node.children);
|
|
185
184
|
});
|
|
186
|
-
} else {
|
|
187
|
-
const ix = common.findFirst(query, encodedKey);
|
|
188
|
-
if (!query[ix] || common.cmp(query[ix].key, encodedKey) !== 0)
|
|
189
|
-
return [];
|
|
190
|
-
const [{ children: subQuery }] = query.splice(ix, 1);
|
|
191
|
-
return addDefQuery(subQuery);
|
|
192
185
|
}
|
|
186
|
+
const ix = common.findFirst(query, encodedKey);
|
|
187
|
+
if (!query[ix] || common.cmp(query[ix].key, encodedKey) !== 0)
|
|
188
|
+
return [];
|
|
189
|
+
const [{ children: subQuery }] = query.splice(ix, 1);
|
|
190
|
+
return addDefQuery(subQuery);
|
|
193
191
|
}
|
|
194
192
|
let used = [];
|
|
195
193
|
if (key[0] === "$") {
|
package/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { encodePath, splitRef, findFirst, cmp, unwrap, merge, wrap, splitArgs, encodeArgs, decodeArgs, isBranch, add, MIN_KEY, encodeQuery, finalize, unpack, pack } from "@graffy/common";
|
|
2
2
|
import debug from "debug";
|
|
3
3
|
function linkGraph(rootGraph, defs) {
|
|
4
|
-
|
|
4
|
+
const version = rootGraph[0].version;
|
|
5
5
|
for (const { path, def } of defs) {
|
|
6
6
|
const braid = def.map(getChoices);
|
|
7
7
|
const strands = unbraid(braid);
|
|
@@ -73,7 +73,7 @@ function linkGraph(rootGraph, defs) {
|
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
const encodedKey = encodeArgs(key).key;
|
|
76
|
-
|
|
76
|
+
const node = graph[findFirst(graph, encodedKey)];
|
|
77
77
|
if (!node || cmp(node.key, encodedKey) !== 0 || node.end)
|
|
78
78
|
return [];
|
|
79
79
|
return recurse(node, rest, vars);
|
|
@@ -162,9 +162,8 @@ function prepQueryLinks(rootQuery, defs) {
|
|
|
162
162
|
)
|
|
163
163
|
};
|
|
164
164
|
});
|
|
165
|
-
} else {
|
|
166
|
-
return [{ path, def: prepareDef(def, vars) }];
|
|
167
165
|
}
|
|
166
|
+
return [{ path, def: prepareDef(def, vars) }];
|
|
168
167
|
}
|
|
169
168
|
function prefixKey(defs2, key2) {
|
|
170
169
|
return defs2.map(({ path: path2, def: def2 }) => ({
|
|
@@ -182,13 +181,12 @@ function prepQueryLinks(rootQuery, defs) {
|
|
|
182
181
|
vars[key.slice(1)] = decodeArgs(node);
|
|
183
182
|
return addDefQuery(node.children);
|
|
184
183
|
});
|
|
185
|
-
} else {
|
|
186
|
-
const ix = findFirst(query, encodedKey);
|
|
187
|
-
if (!query[ix] || cmp(query[ix].key, encodedKey) !== 0)
|
|
188
|
-
return [];
|
|
189
|
-
const [{ children: subQuery }] = query.splice(ix, 1);
|
|
190
|
-
return addDefQuery(subQuery);
|
|
191
184
|
}
|
|
185
|
+
const ix = findFirst(query, encodedKey);
|
|
186
|
+
if (!query[ix] || cmp(query[ix].key, encodedKey) !== 0)
|
|
187
|
+
return [];
|
|
188
|
+
const [{ children: subQuery }] = query.splice(ix, 1);
|
|
189
|
+
return addDefQuery(subQuery);
|
|
192
190
|
}
|
|
193
191
|
let used = [];
|
|
194
192
|
if (key[0] === "$") {
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graffy/link",
|
|
3
3
|
"description": "Graffy module for constructing links using an intuitive, declarative notation.",
|
|
4
4
|
"author": "aravind (https://github.com/aravindet)",
|
|
5
|
-
"version": "0.16.
|
|
5
|
+
"version": "0.16.11",
|
|
6
6
|
"main": "./index.cjs",
|
|
7
7
|
"exports": {
|
|
8
8
|
"import": "./index.mjs",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"license": "Apache-2.0",
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@graffy/common": "0.16.
|
|
19
|
+
"@graffy/common": "0.16.11",
|
|
20
20
|
"debug": "^4.3.3"
|
|
21
21
|
}
|
|
22
22
|
}
|