@calcit/procs 0.9.9 → 0.9.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/README.md +1 -1
- package/lib/calcit.procs.mjs +11 -0
- package/lib/package.json +1 -1
- package/package.json +1 -1
- package/ts-src/calcit.procs.mts +12 -0
package/README.md
CHANGED
package/lib/calcit.procs.mjs
CHANGED
|
@@ -1170,6 +1170,17 @@ export let transform_code_to_cirru = (x) => {
|
|
|
1170
1170
|
export let js_array = (...xs) => {
|
|
1171
1171
|
return xs;
|
|
1172
1172
|
};
|
|
1173
|
+
/** for..await alternative with function */
|
|
1174
|
+
export let js_for_await = async (stream, f) => {
|
|
1175
|
+
if (typeof f !== "function") {
|
|
1176
|
+
throw new Error(`Expected function for: ${f}`);
|
|
1177
|
+
}
|
|
1178
|
+
let ret = null;
|
|
1179
|
+
for await (let item of stream) {
|
|
1180
|
+
ret = await f(item);
|
|
1181
|
+
}
|
|
1182
|
+
return ret;
|
|
1183
|
+
};
|
|
1173
1184
|
export let _$n_js_object = (...xs) => {
|
|
1174
1185
|
if (xs.length % 2 !== 0) {
|
|
1175
1186
|
throw new Error("&js-object expects even number of arguments");
|
package/lib/package.json
CHANGED
package/package.json
CHANGED
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -1255,6 +1255,18 @@ export let js_array = (...xs: CalcitValue[]): CalcitValue[] => {
|
|
|
1255
1255
|
return xs;
|
|
1256
1256
|
};
|
|
1257
1257
|
|
|
1258
|
+
/** for..await alternative with function */
|
|
1259
|
+
export let js_for_await = async (stream: AsyncIterableIterator<CalcitValue>, f: (v: CalcitValue) => Promise<CalcitValue>) => {
|
|
1260
|
+
if (typeof f !== "function") {
|
|
1261
|
+
throw new Error(`Expected function for: ${f}`);
|
|
1262
|
+
}
|
|
1263
|
+
let ret = null;
|
|
1264
|
+
for await (let item of stream) {
|
|
1265
|
+
ret = await f(item);
|
|
1266
|
+
}
|
|
1267
|
+
return ret
|
|
1268
|
+
}
|
|
1269
|
+
|
|
1258
1270
|
export let _$n_js_object = (...xs: CalcitValue[]): Record<string, CalcitValue> => {
|
|
1259
1271
|
if (xs.length % 2 !== 0) {
|
|
1260
1272
|
throw new Error("&js-object expects even number of arguments");
|