@calcit/procs 0.8.8 → 0.8.10
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/lib/calcit.procs.mjs +17 -1
- package/lib/custom-formatter.mjs +13 -0
- package/lib/js-cirru.mjs +16 -0
- package/package.json +2 -2
- package/rust-toolchain.toml +3 -0
- package/ts-src/calcit.procs.mts +17 -1
- package/ts-src/custom-formatter.mts +11 -0
- package/ts-src/js-cirru.mts +14 -0
package/lib/calcit.procs.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
// CALCIT VERSION
|
|
3
|
-
export const calcit_version = "0.8.
|
|
3
|
+
export const calcit_version = "0.8.10";
|
|
4
4
|
import { parse } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
6
6
|
import { CalcitSymbol, CalcitTag, CalcitRef, CalcitRecur, newTag, refsRegistry, toString, getStringName, _$n__$e_, hashFunction, } from "./calcit-data.mjs";
|
|
@@ -1377,6 +1377,22 @@ export let _$n_buffer = (...xs) => {
|
|
|
1377
1377
|
}
|
|
1378
1378
|
return buf;
|
|
1379
1379
|
};
|
|
1380
|
+
export let _$n_cirru_nth = (xs, idx) => {
|
|
1381
|
+
if (xs instanceof CalcitCirruQuote) {
|
|
1382
|
+
return xs.nth(idx);
|
|
1383
|
+
}
|
|
1384
|
+
else {
|
|
1385
|
+
throw new Error("Expected a Cirru Quote");
|
|
1386
|
+
}
|
|
1387
|
+
};
|
|
1388
|
+
export let _$n_cirru_type = (xs, idx) => {
|
|
1389
|
+
if (xs instanceof CalcitCirruQuote) {
|
|
1390
|
+
return Array.isArray(xs.value) ? newTag("list") : newTag("leaf");
|
|
1391
|
+
}
|
|
1392
|
+
else {
|
|
1393
|
+
throw new Error("Expected a Cirru Quote");
|
|
1394
|
+
}
|
|
1395
|
+
};
|
|
1380
1396
|
export let _$n_hash = (x) => {
|
|
1381
1397
|
return hashFunction(x);
|
|
1382
1398
|
};
|
package/lib/custom-formatter.mjs
CHANGED
|
@@ -126,6 +126,19 @@ export let load_console_formatter_$x_ = () => {
|
|
|
126
126
|
if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
|
|
127
127
|
let ret = ["div", { style: "color: hsl(280, 80%, 60%)" }];
|
|
128
128
|
let pairs = obj.pairs();
|
|
129
|
+
pairs.sort((pa, pb) => {
|
|
130
|
+
let ka = pa[0].toString();
|
|
131
|
+
let kb = pb[0].toString();
|
|
132
|
+
if (ka < kb) {
|
|
133
|
+
return -1;
|
|
134
|
+
}
|
|
135
|
+
else if (ka > kb) {
|
|
136
|
+
return 1;
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
});
|
|
129
142
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
130
143
|
let [k, v] = pairs[idx];
|
|
131
144
|
ret.push([
|
package/lib/js-cirru.mjs
CHANGED
|
@@ -9,6 +9,9 @@ import { CalcitTuple } from "./js-tuple.mjs";
|
|
|
9
9
|
import { deepEqual } from "@calcit/ternary-tree/lib/utils.mjs";
|
|
10
10
|
export class CalcitCirruQuote {
|
|
11
11
|
constructor(value) {
|
|
12
|
+
if (value == null) {
|
|
13
|
+
throw new Error("cirru node cannot be null");
|
|
14
|
+
}
|
|
12
15
|
this.value = value;
|
|
13
16
|
}
|
|
14
17
|
toString() {
|
|
@@ -17,6 +20,19 @@ export class CalcitCirruQuote {
|
|
|
17
20
|
toList() {
|
|
18
21
|
return to_calcit_data(this.value, true);
|
|
19
22
|
}
|
|
23
|
+
nth(idx) {
|
|
24
|
+
if (Array.isArray(this.value)) {
|
|
25
|
+
if (idx < this.value.length) {
|
|
26
|
+
return new CalcitCirruQuote(this.value[idx]);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new Error(`nth out of range: ${idx}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
throw new Error(`&cirru-nth does not read into a string: ${this.value}`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
20
36
|
/** provide a simple text representation in Console or std out, with indentations */
|
|
21
37
|
textForm() {
|
|
22
38
|
if (Array.isArray(this.value) && this.value.every((x) => Array.isArray(x))) {
|
package/package.json
CHANGED
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// CALCIT VERSION
|
|
2
|
-
export const calcit_version = "0.8.
|
|
2
|
+
export const calcit_version = "0.8.10";
|
|
3
3
|
|
|
4
4
|
import { parse, ICirruNode } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
@@ -1475,6 +1475,22 @@ export let _$n_buffer = (...xs: CalcitValue[]): Uint8Array => {
|
|
|
1475
1475
|
return buf;
|
|
1476
1476
|
};
|
|
1477
1477
|
|
|
1478
|
+
export let _$n_cirru_nth = (xs: CalcitCirruQuote, idx: number) => {
|
|
1479
|
+
if (xs instanceof CalcitCirruQuote) {
|
|
1480
|
+
return xs.nth(idx);
|
|
1481
|
+
} else {
|
|
1482
|
+
throw new Error("Expected a Cirru Quote");
|
|
1483
|
+
}
|
|
1484
|
+
};
|
|
1485
|
+
|
|
1486
|
+
export let _$n_cirru_type = (xs: CalcitCirruQuote, idx: number) => {
|
|
1487
|
+
if (xs instanceof CalcitCirruQuote) {
|
|
1488
|
+
return Array.isArray(xs.value) ? newTag("list") : newTag("leaf");
|
|
1489
|
+
} else {
|
|
1490
|
+
throw new Error("Expected a Cirru Quote");
|
|
1491
|
+
}
|
|
1492
|
+
};
|
|
1493
|
+
|
|
1478
1494
|
export let _$n_hash = (x: CalcitValue): number => {
|
|
1479
1495
|
return hashFunction(x);
|
|
1480
1496
|
};
|
|
@@ -143,6 +143,17 @@ export let load_console_formatter_$x_ = () => {
|
|
|
143
143
|
if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
|
|
144
144
|
let ret: any[] = ["div", { style: "color: hsl(280, 80%, 60%)" }];
|
|
145
145
|
let pairs = obj.pairs();
|
|
146
|
+
pairs.sort((pa, pb) => {
|
|
147
|
+
let ka = pa[0].toString();
|
|
148
|
+
let kb = pb[0].toString();
|
|
149
|
+
if (ka < kb) {
|
|
150
|
+
return -1;
|
|
151
|
+
} else if (ka > kb) {
|
|
152
|
+
return 1;
|
|
153
|
+
} else {
|
|
154
|
+
return 0;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
146
157
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
147
158
|
let [k, v] = pairs[idx];
|
|
148
159
|
ret.push([
|
package/ts-src/js-cirru.mts
CHANGED
|
@@ -15,6 +15,9 @@ type CirruEdnFormat = string | CirruEdnFormat[];
|
|
|
15
15
|
export class CalcitCirruQuote {
|
|
16
16
|
value: CirruWriterNode;
|
|
17
17
|
constructor(value: CirruWriterNode) {
|
|
18
|
+
if (value == null) {
|
|
19
|
+
throw new Error("cirru node cannot be null");
|
|
20
|
+
}
|
|
18
21
|
this.value = value;
|
|
19
22
|
}
|
|
20
23
|
toString(): string {
|
|
@@ -23,6 +26,17 @@ export class CalcitCirruQuote {
|
|
|
23
26
|
toList(): CalcitValue {
|
|
24
27
|
return to_calcit_data(this.value, true);
|
|
25
28
|
}
|
|
29
|
+
nth(idx: number): CalcitValue {
|
|
30
|
+
if (Array.isArray(this.value)) {
|
|
31
|
+
if (idx < this.value.length) {
|
|
32
|
+
return new CalcitCirruQuote(this.value[idx]);
|
|
33
|
+
} else {
|
|
34
|
+
throw new Error(`nth out of range: ${idx}`);
|
|
35
|
+
}
|
|
36
|
+
} else {
|
|
37
|
+
throw new Error(`&cirru-nth does not read into a string: ${this.value}`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
26
40
|
/** provide a simple text representation in Console or std out, with indentations */
|
|
27
41
|
textForm(): string {
|
|
28
42
|
if (Array.isArray(this.value) && this.value.every((x) => Array.isArray(x))) {
|