@weborigami/language 0.6.15 → 0.6.17
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@weborigami/language",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.17",
|
|
4
4
|
"description": "Web Origami expression language compiler and runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./main.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"typescript": "5.9.3"
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
|
-
"@weborigami/async-tree": "0.6.
|
|
14
|
+
"@weborigami/async-tree": "0.6.17",
|
|
15
15
|
"exif-parser": "0.1.12",
|
|
16
16
|
"watcher": "2.3.1",
|
|
17
17
|
"yaml": "2.8.2"
|
|
@@ -40,7 +40,7 @@ export default {
|
|
|
40
40
|
|
|
41
41
|
// Return a function that adds the given extension
|
|
42
42
|
function addExtension(resultExtension) {
|
|
43
|
-
|
|
43
|
+
const keyFn = (sourceValue, sourceKey) => {
|
|
44
44
|
if (sourceKey === undefined) {
|
|
45
45
|
return undefined;
|
|
46
46
|
}
|
|
@@ -51,4 +51,6 @@ function addExtension(resultExtension) {
|
|
|
51
51
|
: normalizedKey + resultExtension;
|
|
52
52
|
return resultKey;
|
|
53
53
|
};
|
|
54
|
+
keyFn.needsSourceValue = false;
|
|
55
|
+
return keyFn;
|
|
54
56
|
}
|
package/src/runtime/ops.js
CHANGED
|
@@ -92,7 +92,7 @@ export async function cache(cache, path, code) {
|
|
|
92
92
|
}
|
|
93
93
|
|
|
94
94
|
// Don't await: might get another request for this before promise resolves
|
|
95
|
-
const promise =
|
|
95
|
+
const promise = execute(code);
|
|
96
96
|
|
|
97
97
|
// Save promise so another request will get the same promise
|
|
98
98
|
cache[path] = promise;
|
|
@@ -178,7 +178,10 @@ addOpLabel(exponentiation, "«ops.exponentiation»");
|
|
|
178
178
|
* @param {...any} args
|
|
179
179
|
*/
|
|
180
180
|
export async function flat(...args) {
|
|
181
|
-
|
|
181
|
+
// Unpack packed arguments so they can be flattened
|
|
182
|
+
const unpacked = args.map((arg) => (isUnpackable(arg) ? arg.unpack() : arg));
|
|
183
|
+
// Flatten to depth 2: 1 for args array, 1 for flattening
|
|
184
|
+
return Tree.flat(unpacked, 2);
|
|
182
185
|
}
|
|
183
186
|
addOpLabel(flat, "«ops.flat»");
|
|
184
187
|
|
|
@@ -258,7 +261,8 @@ export function lambda(length, parameters, code, state = {}) {
|
|
|
258
261
|
// interim stack frame.
|
|
259
262
|
const interimStack = stack.slice();
|
|
260
263
|
interimStack.push(args);
|
|
261
|
-
const
|
|
264
|
+
const paramState = { ...state, stack: interimStack };
|
|
265
|
+
const frame = await expressionObject(parameters, paramState);
|
|
262
266
|
// Record which code this stack frame is associated with
|
|
263
267
|
Object.defineProperty(frame, codeSymbol, {
|
|
264
268
|
value: code,
|
|
@@ -249,19 +249,19 @@ evaluating: \x1B[31mfile.foo/\x1B[0m`,
|
|
|
249
249
|
);
|
|
250
250
|
});
|
|
251
251
|
|
|
252
|
-
test("identifies when
|
|
252
|
+
test("identifies when data was already unpacked", async () => {
|
|
253
253
|
const parent = {
|
|
254
254
|
a: {
|
|
255
|
-
b: 1,
|
|
255
|
+
"b.json": 1,
|
|
256
256
|
},
|
|
257
257
|
};
|
|
258
258
|
await assertError(
|
|
259
|
-
`a/b/`,
|
|
259
|
+
`a/b.json/`,
|
|
260
260
|
`TraverseError: A path tried to unpack data that's already unpacked.
|
|
261
|
-
Tried to traverse path: a/b/
|
|
262
|
-
Stopped unexpectedly at: b/
|
|
263
|
-
You can drop the trailing slash and just use: b
|
|
264
|
-
evaluating: \x1B[31mb/\x1B[0m`,
|
|
261
|
+
Tried to traverse path: a/b.json/
|
|
262
|
+
Stopped unexpectedly at: b.json/
|
|
263
|
+
You can drop the trailing slash and just use: b.json
|
|
264
|
+
evaluating: \x1B[31mb.json/\x1B[0m`,
|
|
265
265
|
{ parent },
|
|
266
266
|
);
|
|
267
267
|
});
|
package/test/runtime/ops.test.js
CHANGED
|
@@ -158,7 +158,8 @@ describe("ops", () => {
|
|
|
158
158
|
d: 4,
|
|
159
159
|
});
|
|
160
160
|
const array = [5, 6];
|
|
161
|
-
const
|
|
161
|
+
const set = new Set([7, 8]);
|
|
162
|
+
const result = await ops.flat(object, tree, array, set);
|
|
162
163
|
assert.deepEqual(await Tree.plain(result), {
|
|
163
164
|
a: 1,
|
|
164
165
|
b: 2,
|
|
@@ -166,6 +167,8 @@ describe("ops", () => {
|
|
|
166
167
|
d: 4,
|
|
167
168
|
0: 5,
|
|
168
169
|
1: 6,
|
|
170
|
+
2: 7,
|
|
171
|
+
3: 8,
|
|
169
172
|
});
|
|
170
173
|
});
|
|
171
174
|
});
|