@mark1russell7/vex 0.13.4 → 0.14.0
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/build/index.d.ts +21 -13
- package/build/index.d.ts.map +1 -1
- package/build/index.js +218 -43
- package/build/index.js.map +1 -1
- package/package.json +2 -2
- package/src/builder.ts +58 -13
- package/src/deps.ts +3 -1
- package/src/document.ts +24 -7
- package/src/evaluate.ts +47 -14
- package/src/ir.ts +25 -10
- package/src/item-names.ts +29 -0
- package/src/kernel.ts +49 -10
- package/src/write.ts +7 -2
package/src/write.ts
CHANGED
|
@@ -50,6 +50,9 @@ const NONE: readonly Job[] = [];
|
|
|
50
50
|
const term = (e: Expr): Job => ({ t: "term", e });
|
|
51
51
|
const envelope = (e: Expr): Job => ({ t: "envelope", e });
|
|
52
52
|
|
|
53
|
+
/** This function gives the field `as` of a loop: a new list of its names, or no field (AXIS.LIST.SCOPE). */
|
|
54
|
+
const itemsOf = (as: readonly string[] | undefined): { readonly as?: Json } => (as === undefined ? {} : { as: [...as] });
|
|
55
|
+
|
|
53
56
|
/** This function gives a record from names and the documents of their values, from an index of the documents. */
|
|
54
57
|
function namesOf(names: readonly string[], docs: readonly Json[], from: number): JsonRecord {
|
|
55
58
|
const out: Record<string, Json> = {};
|
|
@@ -148,7 +151,8 @@ class Writer {
|
|
|
148
151
|
const axis = docs[0] as Json;
|
|
149
152
|
const body = docs[1] as Json;
|
|
150
153
|
const address = at.make(docs.slice(2));
|
|
151
|
-
|
|
154
|
+
const as = itemsOf(e.as);
|
|
155
|
+
return this.#keep(typed("each", reads ? { body, axis, ...as, ...address } : { axis, ...as, body, ...address }), e);
|
|
152
156
|
},
|
|
153
157
|
};
|
|
154
158
|
}
|
|
@@ -164,7 +168,8 @@ class Writer {
|
|
|
164
168
|
const names = { init: namesOf(init, docs, 1), step: namesOf(step, docs, 1 + init.length) };
|
|
165
169
|
const result = docs[after] as Json;
|
|
166
170
|
const address = at.make(docs.slice(after + 1));
|
|
167
|
-
|
|
171
|
+
const as = itemsOf(e.as);
|
|
172
|
+
return this.#keep(typed("fold", reads ? { ...names, axis, ...as, ...address, result } : { axis, ...as, ...names, result, ...address }), e);
|
|
168
173
|
},
|
|
169
174
|
};
|
|
170
175
|
}
|