@calcit/procs 0.8.46 → 0.8.48
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-data.mjs +8 -4
- package/lib/calcit.procs.mjs +6 -3
- package/lib/custom-formatter.mjs +8 -3
- package/lib/js-cirru.mjs +27 -19
- package/lib/js-list.mjs +8 -4
- package/lib/js-map.mjs +12 -4
- package/lib/js-record.mjs +2 -1
- package/lib/package.json +2 -2
- package/package.json +2 -2
- package/ts-src/calcit-data.mts +8 -4
- package/ts-src/calcit.procs.mts +6 -3
- package/ts-src/custom-formatter.mts +8 -3
- package/ts-src/js-cirru.mts +26 -17
- package/ts-src/js-list.mts +8 -4
- package/ts-src/js-map.mts +12 -4
- package/ts-src/js-record.mts +2 -1
package/lib/calcit-data.mjs
CHANGED
|
@@ -258,7 +258,8 @@ export let hashFunction = (x) => {
|
|
|
258
258
|
let pairs = x.pairs();
|
|
259
259
|
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
260
260
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
261
|
-
let
|
|
261
|
+
let k = pairs[idx][0];
|
|
262
|
+
let v = pairs[idx][1];
|
|
262
263
|
base = mergeValueHash(base, hashFunction(k));
|
|
263
264
|
base = mergeValueHash(base, hashFunction(v));
|
|
264
265
|
}
|
|
@@ -270,7 +271,8 @@ export let hashFunction = (x) => {
|
|
|
270
271
|
let pairs = x.pairs();
|
|
271
272
|
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
272
273
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
273
|
-
let
|
|
274
|
+
let k = pairs[idx][0];
|
|
275
|
+
let v = pairs[idx][1];
|
|
274
276
|
base = mergeValueHash(base, hashFunction(k));
|
|
275
277
|
base = mergeValueHash(base, hashFunction(v));
|
|
276
278
|
}
|
|
@@ -421,7 +423,8 @@ export let to_js_data = (x, addColon = false) => {
|
|
|
421
423
|
let result = {};
|
|
422
424
|
let pairs = x.pairs();
|
|
423
425
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
424
|
-
let
|
|
426
|
+
let k = pairs[idx][0];
|
|
427
|
+
let v = pairs[idx][1];
|
|
425
428
|
var key = to_js_data(k, addColon);
|
|
426
429
|
result[key] = to_js_data(v, addColon);
|
|
427
430
|
}
|
|
@@ -527,7 +530,8 @@ export let _$n__$e_ = (x, y) => {
|
|
|
527
530
|
}
|
|
528
531
|
let pairs = x.pairs();
|
|
529
532
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
530
|
-
let
|
|
533
|
+
let k = pairs[idx][0];
|
|
534
|
+
let v = pairs[idx][1];
|
|
531
535
|
if (!y.contains(k)) {
|
|
532
536
|
return false;
|
|
533
537
|
}
|
package/lib/calcit.procs.mjs
CHANGED
|
@@ -383,7 +383,8 @@ export let reset_$x_ = (a, v) => {
|
|
|
383
383
|
}
|
|
384
384
|
let prev = a.value;
|
|
385
385
|
a.value = v;
|
|
386
|
-
for (let
|
|
386
|
+
for (let k in a.listeners) {
|
|
387
|
+
let f = a.listeners.get(k);
|
|
387
388
|
f(v, prev);
|
|
388
389
|
}
|
|
389
390
|
return null;
|
|
@@ -687,7 +688,8 @@ export let _$n_merge = (a, b) => {
|
|
|
687
688
|
}
|
|
688
689
|
let pairs = b.pairs();
|
|
689
690
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
690
|
-
let
|
|
691
|
+
let k = pairs[idx][0];
|
|
692
|
+
let v = pairs[idx][1];
|
|
691
693
|
let field;
|
|
692
694
|
if (k instanceof CalcitTag) {
|
|
693
695
|
field = k;
|
|
@@ -1279,7 +1281,8 @@ export function invoke_method(p, obj, ...args) {
|
|
|
1279
1281
|
if (pair == null) {
|
|
1280
1282
|
throw new Error(`No class for ${obj?.toString() || JSON.stringify(obj)} to lookup .${p}`);
|
|
1281
1283
|
}
|
|
1282
|
-
let
|
|
1284
|
+
let klass = pair[0];
|
|
1285
|
+
let tag = pair[1];
|
|
1283
1286
|
let method = klass.getOrNil(p);
|
|
1284
1287
|
if (method == null) {
|
|
1285
1288
|
throw new Error(`No method '.${p}' for '${tag}' object '${obj}'.\navailable fields are: ${klass.fields.map((fd) => fd.value).join(" ")}`);
|
package/lib/custom-formatter.mjs
CHANGED
|
@@ -92,7 +92,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
92
92
|
if (obj instanceof CalcitList || obj instanceof CalcitSliceList) {
|
|
93
93
|
let preview = "";
|
|
94
94
|
let hasCollection = false;
|
|
95
|
-
|
|
95
|
+
let size = obj.len();
|
|
96
|
+
for (let idx = 0; idx < size; idx++) {
|
|
96
97
|
preview += " ";
|
|
97
98
|
if (isLiteral(obj.get(idx))) {
|
|
98
99
|
preview += saveString(obj.get(idx));
|
|
@@ -115,7 +116,10 @@ export let load_console_formatter_$x_ = () => {
|
|
|
115
116
|
if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
|
|
116
117
|
let preview = "";
|
|
117
118
|
let hasCollection = false;
|
|
118
|
-
|
|
119
|
+
let pairs = obj.pairs();
|
|
120
|
+
for (let idx = 0; idx < pairs.length; idx++) {
|
|
121
|
+
let k = pairs[idx][0];
|
|
122
|
+
let v = pairs[idx][1];
|
|
119
123
|
preview += " ";
|
|
120
124
|
if (isLiteral(k) && isLiteral(v)) {
|
|
121
125
|
preview += `(${saveString(k)} ${saveString(v)})`;
|
|
@@ -242,7 +246,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
242
246
|
}
|
|
243
247
|
});
|
|
244
248
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
245
|
-
let
|
|
249
|
+
let k = pairs[idx][0];
|
|
250
|
+
let v = pairs[idx][1];
|
|
246
251
|
ret.push(tr({}, td({ paddingLeft: "8px", verticalAlign: "top", whiteSpace: "nowrap", minWidth: "40px" }, embedObject(k)), td({ paddingLeft: "8px" }, embedObject(v))));
|
|
247
252
|
}
|
|
248
253
|
return ret;
|
package/lib/js-cirru.mjs
CHANGED
|
@@ -68,10 +68,10 @@ export let to_cirru_edn = (x) => {
|
|
|
68
68
|
return `|${x}`;
|
|
69
69
|
}
|
|
70
70
|
if (typeof x === "number") {
|
|
71
|
-
return x
|
|
71
|
+
return `${x}`;
|
|
72
72
|
}
|
|
73
73
|
if (typeof x === "boolean") {
|
|
74
|
-
return x
|
|
74
|
+
return `${x}`;
|
|
75
75
|
}
|
|
76
76
|
if (x instanceof CalcitTag) {
|
|
77
77
|
return x.toString();
|
|
@@ -80,8 +80,12 @@ export let to_cirru_edn = (x) => {
|
|
|
80
80
|
return x.toString();
|
|
81
81
|
}
|
|
82
82
|
if (x instanceof CalcitList || x instanceof CalcitSliceList) {
|
|
83
|
-
|
|
84
|
-
|
|
83
|
+
let ret = ["[]"];
|
|
84
|
+
let arr = x.toArray();
|
|
85
|
+
for (let idx = 0; idx < arr.length; idx++) {
|
|
86
|
+
ret.push(to_cirru_edn(arr[idx]));
|
|
87
|
+
}
|
|
88
|
+
return ret;
|
|
85
89
|
}
|
|
86
90
|
if (x instanceof CalcitCirruQuote) {
|
|
87
91
|
return ["quote", x.value];
|
|
@@ -120,30 +124,21 @@ export let to_cirru_edn = (x) => {
|
|
|
120
124
|
}
|
|
121
125
|
});
|
|
122
126
|
for (let idx = 0; idx < pairs_buffer.length; idx++) {
|
|
123
|
-
let
|
|
127
|
+
let k = pairs_buffer[idx][0];
|
|
128
|
+
let v = pairs_buffer[idx][1];
|
|
124
129
|
buffer.push([to_cirru_edn(k), to_cirru_edn(v)]);
|
|
125
130
|
}
|
|
126
131
|
return buffer;
|
|
127
132
|
}
|
|
128
133
|
if (x instanceof CalcitRecord) {
|
|
129
|
-
let buffer = [
|
|
134
|
+
let buffer = [];
|
|
130
135
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
131
136
|
buffer.push([x.fields[idx].toString(), to_cirru_edn(x.values[idx])]);
|
|
132
137
|
}
|
|
133
138
|
// placed literals first
|
|
134
|
-
buffer.sort(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (a1_literal && !b1_literal) {
|
|
138
|
-
return -1;
|
|
139
|
-
}
|
|
140
|
-
else if (!a1_literal && b1_literal) {
|
|
141
|
-
return 1;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
return _$n_compare(a[0], b[0]);
|
|
145
|
-
}
|
|
146
|
-
});
|
|
139
|
+
buffer.sort(recordFieldOrder);
|
|
140
|
+
buffer.unshift(x.name.toString());
|
|
141
|
+
buffer.unshift("%{}");
|
|
147
142
|
return buffer;
|
|
148
143
|
}
|
|
149
144
|
if (x instanceof CalcitSet) {
|
|
@@ -176,6 +171,19 @@ export let to_cirru_edn = (x) => {
|
|
|
176
171
|
console.error(x);
|
|
177
172
|
throw new Error("Unexpected data to to-cirru-edn");
|
|
178
173
|
};
|
|
174
|
+
let recordFieldOrder = (a, b) => {
|
|
175
|
+
let a1_literal = isLiteral(a[1]);
|
|
176
|
+
let b1_literal = isLiteral(b[1]);
|
|
177
|
+
if (a1_literal && !b1_literal) {
|
|
178
|
+
return -1;
|
|
179
|
+
}
|
|
180
|
+
else if (!a1_literal && b1_literal) {
|
|
181
|
+
return 1;
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
return _$n_compare(a[0], b[0]);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
179
187
|
/** makes sure we got string */
|
|
180
188
|
let extractFieldTag = (x) => {
|
|
181
189
|
if (x[0] === ":") {
|
package/lib/js-list.mjs
CHANGED
|
@@ -92,7 +92,8 @@ export class CalcitList {
|
|
|
92
92
|
return new CalcitList(ternaryTree.reverse(this.value));
|
|
93
93
|
}
|
|
94
94
|
nestedDataInChildren() {
|
|
95
|
-
|
|
95
|
+
let size = this.len();
|
|
96
|
+
for (let idx = 0; idx < size; idx++) {
|
|
96
97
|
if (!isLiteral(this.get(idx))) {
|
|
97
98
|
return true;
|
|
98
99
|
}
|
|
@@ -247,7 +248,8 @@ export class CalcitSliceList {
|
|
|
247
248
|
return this.turnListMode().reverse();
|
|
248
249
|
}
|
|
249
250
|
nestedDataInChildren() {
|
|
250
|
-
|
|
251
|
+
let size = this.len();
|
|
252
|
+
for (let idx = 0; idx < size; idx++) {
|
|
251
253
|
if (!isLiteral(this.get(idx))) {
|
|
252
254
|
return true;
|
|
253
255
|
}
|
|
@@ -275,7 +277,8 @@ export let foldl = function (xs, acc, f) {
|
|
|
275
277
|
}
|
|
276
278
|
if (xs instanceof CalcitSliceList || xs instanceof CalcitList) {
|
|
277
279
|
var result = acc;
|
|
278
|
-
|
|
280
|
+
let size = xs.len();
|
|
281
|
+
for (let idx = 0; idx < size; idx++) {
|
|
279
282
|
let item = xs.get(idx);
|
|
280
283
|
result = f(result, item);
|
|
281
284
|
}
|
|
@@ -316,7 +319,8 @@ export let foldl_shortcut = function (xs, acc, v0, f) {
|
|
|
316
319
|
}
|
|
317
320
|
if (xs instanceof CalcitList || xs instanceof CalcitSliceList) {
|
|
318
321
|
var state = acc;
|
|
319
|
-
|
|
322
|
+
let size = xs.len();
|
|
323
|
+
for (let idx = 0; idx < size; idx++) {
|
|
320
324
|
let item = xs.get(idx);
|
|
321
325
|
let pair = f(state, item);
|
|
322
326
|
if (pair instanceof CalcitTuple) {
|
package/lib/js-map.mjs
CHANGED
|
@@ -50,7 +50,8 @@ export class CalcitMap {
|
|
|
50
50
|
let itemsCode = "";
|
|
51
51
|
let pairs = this.pairs();
|
|
52
52
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
53
|
-
let
|
|
53
|
+
let k = pairs[idx][0];
|
|
54
|
+
let v = pairs[idx][1];
|
|
54
55
|
if (shorter) {
|
|
55
56
|
let keyPart = isNestedCalcitData(k) ? tipNestedCalcitData(k) : toString(k, true, disableJsDataWarning);
|
|
56
57
|
let valuePart = isNestedCalcitData(v) ? tipNestedCalcitData(v) : toString(v, true, disableJsDataWarning);
|
|
@@ -155,7 +156,10 @@ export class CalcitMap {
|
|
|
155
156
|
}
|
|
156
157
|
/** detecthing in custom formatter */
|
|
157
158
|
nestedDataInChildren() {
|
|
158
|
-
|
|
159
|
+
let pairs = this.pairs();
|
|
160
|
+
for (let idx = 0; idx < pairs.length; idx++) {
|
|
161
|
+
let k = pairs[idx][0];
|
|
162
|
+
let v = pairs[idx][1];
|
|
159
163
|
if (!isLiteral(k) || !isLiteral(v)) {
|
|
160
164
|
return true;
|
|
161
165
|
}
|
|
@@ -247,7 +251,8 @@ export class CalcitSliceMap {
|
|
|
247
251
|
let itemsCode = "";
|
|
248
252
|
let pairs = this.pairs();
|
|
249
253
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
250
|
-
let
|
|
254
|
+
let k = pairs[idx][0];
|
|
255
|
+
let v = pairs[idx][1];
|
|
251
256
|
if (shorter) {
|
|
252
257
|
let keyPart = isNestedCalcitData(k) ? tipNestedCalcitData(k) : toString(k, true, disableJsDataWarning);
|
|
253
258
|
let valuePart = isNestedCalcitData(v) ? tipNestedCalcitData(v) : toString(v, true, disableJsDataWarning);
|
|
@@ -356,7 +361,10 @@ export class CalcitSliceMap {
|
|
|
356
361
|
}
|
|
357
362
|
/** detecthing in custom formatter */
|
|
358
363
|
nestedDataInChildren() {
|
|
359
|
-
|
|
364
|
+
let pairs = this.pairs();
|
|
365
|
+
for (let idx = 0; idx < pairs.length; idx++) {
|
|
366
|
+
let k = pairs[idx][0];
|
|
367
|
+
let v = pairs[idx][1];
|
|
360
368
|
if (!isLiteral(k) || !isLiteral(v)) {
|
|
361
369
|
return true;
|
|
362
370
|
}
|
package/lib/js-record.mjs
CHANGED
|
@@ -182,7 +182,8 @@ export let _$n_record_$o_from_map = (proto, data) => {
|
|
|
182
182
|
let pairs_buffer = [];
|
|
183
183
|
let pairs = data.pairs();
|
|
184
184
|
for (let i = 0; i < pairs.length; i++) {
|
|
185
|
-
let
|
|
185
|
+
let k = pairs[i][0];
|
|
186
|
+
let v = pairs[i][1];
|
|
186
187
|
pairs_buffer.push([castTag(k), v]);
|
|
187
188
|
}
|
|
188
189
|
// mutable sort
|
package/lib/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calcit/procs",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.48",
|
|
4
4
|
"main": "./lib/calcit.procs.mjs",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/node": "^20.11.28",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@calcit/ternary-tree": "0.0.23",
|
|
25
25
|
"@cirru/parser.ts": "^0.0.6",
|
|
26
|
-
"@cirru/writer.ts": "^0.1.
|
|
26
|
+
"@cirru/writer.ts": "^0.1.5"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@calcit/procs",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.48",
|
|
4
4
|
"main": "./lib/calcit.procs.mjs",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@types/node": "^20.11.28",
|
|
@@ -23,6 +23,6 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@calcit/ternary-tree": "0.0.23",
|
|
25
25
|
"@cirru/parser.ts": "^0.0.6",
|
|
26
|
-
"@cirru/writer.ts": "^0.1.
|
|
26
|
+
"@cirru/writer.ts": "^0.1.5"
|
|
27
27
|
}
|
|
28
28
|
}
|
package/ts-src/calcit-data.mts
CHANGED
|
@@ -290,7 +290,8 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
290
290
|
let pairs = x.pairs();
|
|
291
291
|
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
292
292
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
293
|
-
let
|
|
293
|
+
let k = pairs[idx][0];
|
|
294
|
+
let v = pairs[idx][1];
|
|
294
295
|
base = mergeValueHash(base, hashFunction(k));
|
|
295
296
|
base = mergeValueHash(base, hashFunction(v));
|
|
296
297
|
}
|
|
@@ -303,7 +304,8 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
303
304
|
let pairs = x.pairs();
|
|
304
305
|
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
305
306
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
306
|
-
let
|
|
307
|
+
let k = pairs[idx][0];
|
|
308
|
+
let v = pairs[idx][1];
|
|
307
309
|
base = mergeValueHash(base, hashFunction(k));
|
|
308
310
|
base = mergeValueHash(base, hashFunction(v));
|
|
309
311
|
}
|
|
@@ -456,7 +458,8 @@ export let to_js_data = (x: CalcitValue, addColon: boolean = false): any => {
|
|
|
456
458
|
let result: Record<string, CalcitValue> = {};
|
|
457
459
|
let pairs = x.pairs();
|
|
458
460
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
459
|
-
let
|
|
461
|
+
let k = pairs[idx][0];
|
|
462
|
+
let v = pairs[idx][1];
|
|
460
463
|
var key = to_js_data(k, addColon);
|
|
461
464
|
result[key] = to_js_data(v, addColon);
|
|
462
465
|
}
|
|
@@ -569,7 +572,8 @@ export let _$n__$e_ = (x: CalcitValue, y: CalcitValue): boolean => {
|
|
|
569
572
|
}
|
|
570
573
|
let pairs = x.pairs();
|
|
571
574
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
572
|
-
let
|
|
575
|
+
let k = pairs[idx][0];
|
|
576
|
+
let v = pairs[idx][1];
|
|
573
577
|
if (!y.contains(k)) {
|
|
574
578
|
return false;
|
|
575
579
|
}
|
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -437,7 +437,8 @@ export let reset_$x_ = (a: CalcitRef, v: CalcitValue): null => {
|
|
|
437
437
|
}
|
|
438
438
|
let prev = a.value;
|
|
439
439
|
a.value = v;
|
|
440
|
-
for (let
|
|
440
|
+
for (let k in a.listeners) {
|
|
441
|
+
let f = a.listeners.get(k);
|
|
441
442
|
f(v, prev);
|
|
442
443
|
}
|
|
443
444
|
return null;
|
|
@@ -760,7 +761,8 @@ export let _$n_merge = (a: CalcitValue, b: CalcitMap | CalcitSliceMap): CalcitVa
|
|
|
760
761
|
}
|
|
761
762
|
let pairs = b.pairs();
|
|
762
763
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
763
|
-
let
|
|
764
|
+
let k = pairs[idx][0];
|
|
765
|
+
let v = pairs[idx][1];
|
|
764
766
|
let field: CalcitTag;
|
|
765
767
|
if (k instanceof CalcitTag) {
|
|
766
768
|
field = k;
|
|
@@ -1372,7 +1374,8 @@ export function invoke_method(p: string, obj: CalcitValue, ...args: CalcitValue[
|
|
|
1372
1374
|
if (pair == null) {
|
|
1373
1375
|
throw new Error(`No class for ${obj?.toString() || JSON.stringify(obj)} to lookup .${p}`);
|
|
1374
1376
|
}
|
|
1375
|
-
let
|
|
1377
|
+
let klass = pair[0];
|
|
1378
|
+
let tag = pair[1];
|
|
1376
1379
|
let method = klass.getOrNil(p);
|
|
1377
1380
|
if (method == null) {
|
|
1378
1381
|
throw new Error(`No method '.${p}' for '${tag}' object '${obj}'.\navailable fields are: ${klass.fields.map((fd: CalcitTag) => fd.value).join(" ")}`);
|
|
@@ -106,7 +106,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
106
106
|
if (obj instanceof CalcitList || obj instanceof CalcitSliceList) {
|
|
107
107
|
let preview = "";
|
|
108
108
|
let hasCollection = false;
|
|
109
|
-
|
|
109
|
+
let size = obj.len();
|
|
110
|
+
for (let idx = 0; idx < size; idx++) {
|
|
110
111
|
preview += " ";
|
|
111
112
|
if (isLiteral(obj.get(idx))) {
|
|
112
113
|
preview += saveString(obj.get(idx));
|
|
@@ -136,7 +137,10 @@ export let load_console_formatter_$x_ = () => {
|
|
|
136
137
|
if (obj instanceof CalcitMap || obj instanceof CalcitSliceMap) {
|
|
137
138
|
let preview = "";
|
|
138
139
|
let hasCollection = false;
|
|
139
|
-
|
|
140
|
+
let pairs = obj.pairs();
|
|
141
|
+
for (let idx = 0; idx < pairs.length; idx++) {
|
|
142
|
+
let k = pairs[idx][0];
|
|
143
|
+
let v = pairs[idx][1];
|
|
140
144
|
preview += " ";
|
|
141
145
|
if (isLiteral(k) && isLiteral(v)) {
|
|
142
146
|
preview += `(${saveString(k)} ${saveString(v)})`;
|
|
@@ -305,7 +309,8 @@ export let load_console_formatter_$x_ = () => {
|
|
|
305
309
|
}
|
|
306
310
|
});
|
|
307
311
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
308
|
-
let
|
|
312
|
+
let k = pairs[idx][0];
|
|
313
|
+
let v = pairs[idx][1];
|
|
309
314
|
ret.push(
|
|
310
315
|
tr(
|
|
311
316
|
{},
|
package/ts-src/js-cirru.mts
CHANGED
|
@@ -73,10 +73,10 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
|
|
|
73
73
|
return `|${x}`;
|
|
74
74
|
}
|
|
75
75
|
if (typeof x === "number") {
|
|
76
|
-
return x
|
|
76
|
+
return `${x}`;
|
|
77
77
|
}
|
|
78
78
|
if (typeof x === "boolean") {
|
|
79
|
-
return x
|
|
79
|
+
return `${x}`;
|
|
80
80
|
}
|
|
81
81
|
if (x instanceof CalcitTag) {
|
|
82
82
|
return x.toString();
|
|
@@ -85,8 +85,12 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
|
|
|
85
85
|
return x.toString();
|
|
86
86
|
}
|
|
87
87
|
if (x instanceof CalcitList || x instanceof CalcitSliceList) {
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
let ret: CirruEdnFormat[] = ["[]"];
|
|
89
|
+
let arr = x.toArray();
|
|
90
|
+
for (let idx = 0; idx < arr.length; idx++) {
|
|
91
|
+
ret.push(to_cirru_edn(arr[idx]));
|
|
92
|
+
}
|
|
93
|
+
return ret;
|
|
90
94
|
}
|
|
91
95
|
if (x instanceof CalcitCirruQuote) {
|
|
92
96
|
return ["quote", x.value];
|
|
@@ -120,28 +124,21 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
|
|
|
120
124
|
}
|
|
121
125
|
});
|
|
122
126
|
for (let idx = 0; idx < pairs_buffer.length; idx++) {
|
|
123
|
-
let
|
|
127
|
+
let k = pairs_buffer[idx][0];
|
|
128
|
+
let v = pairs_buffer[idx][1];
|
|
124
129
|
buffer.push([to_cirru_edn(k), to_cirru_edn(v)]);
|
|
125
130
|
}
|
|
126
131
|
return buffer;
|
|
127
132
|
}
|
|
128
133
|
if (x instanceof CalcitRecord) {
|
|
129
|
-
let buffer: [string, CirruEdnFormat] = [
|
|
134
|
+
let buffer: [string, CirruEdnFormat][] = [];
|
|
130
135
|
for (let idx = 0; idx < x.fields.length; idx++) {
|
|
131
136
|
buffer.push([x.fields[idx].toString(), to_cirru_edn(x.values[idx])]);
|
|
132
137
|
}
|
|
133
138
|
// placed literals first
|
|
134
|
-
buffer.sort(
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
if (a1_literal && !b1_literal) {
|
|
138
|
-
return -1;
|
|
139
|
-
} else if (!a1_literal && b1_literal) {
|
|
140
|
-
return 1;
|
|
141
|
-
} else {
|
|
142
|
-
return _$n_compare(a[0] as CalcitValue, b[0] as CalcitValue);
|
|
143
|
-
}
|
|
144
|
-
});
|
|
139
|
+
buffer.sort(recordFieldOrder);
|
|
140
|
+
(buffer as any[]).unshift(x.name.toString());
|
|
141
|
+
(buffer as any[]).unshift("%{}");
|
|
145
142
|
return buffer;
|
|
146
143
|
}
|
|
147
144
|
if (x instanceof CalcitSet) {
|
|
@@ -172,6 +169,18 @@ export let to_cirru_edn = (x: CalcitValue): CirruEdnFormat => {
|
|
|
172
169
|
throw new Error("Unexpected data to to-cirru-edn");
|
|
173
170
|
};
|
|
174
171
|
|
|
172
|
+
let recordFieldOrder = (a: [string, CirruEdnFormat], b: [string, CirruEdnFormat]) => {
|
|
173
|
+
let a1_literal = isLiteral(a[1] as CalcitValue);
|
|
174
|
+
let b1_literal = isLiteral(b[1] as CalcitValue);
|
|
175
|
+
if (a1_literal && !b1_literal) {
|
|
176
|
+
return -1;
|
|
177
|
+
} else if (!a1_literal && b1_literal) {
|
|
178
|
+
return 1;
|
|
179
|
+
} else {
|
|
180
|
+
return _$n_compare(a[0] as CalcitValue, b[0] as CalcitValue);
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
175
184
|
/** makes sure we got string */
|
|
176
185
|
let extractFieldTag = (x: string) => {
|
|
177
186
|
if (x[0] === ":") {
|
package/ts-src/js-list.mts
CHANGED
|
@@ -107,7 +107,8 @@ export class CalcitList {
|
|
|
107
107
|
return new CalcitList(ternaryTree.reverse(this.value));
|
|
108
108
|
}
|
|
109
109
|
nestedDataInChildren(): boolean {
|
|
110
|
-
|
|
110
|
+
let size = this.len();
|
|
111
|
+
for (let idx = 0; idx < size; idx++) {
|
|
111
112
|
if (!isLiteral(this.get(idx))) {
|
|
112
113
|
return true;
|
|
113
114
|
}
|
|
@@ -262,7 +263,8 @@ export class CalcitSliceList {
|
|
|
262
263
|
return this.turnListMode().reverse();
|
|
263
264
|
}
|
|
264
265
|
nestedDataInChildren(): boolean {
|
|
265
|
-
|
|
266
|
+
let size = this.len();
|
|
267
|
+
for (let idx = 0; idx < size; idx++) {
|
|
266
268
|
if (!isLiteral(this.get(idx))) {
|
|
267
269
|
return true;
|
|
268
270
|
}
|
|
@@ -292,7 +294,8 @@ export let foldl = function (xs: CalcitValue, acc: CalcitValue, f: CalcitFn): Ca
|
|
|
292
294
|
}
|
|
293
295
|
if (xs instanceof CalcitSliceList || xs instanceof CalcitList) {
|
|
294
296
|
var result = acc;
|
|
295
|
-
|
|
297
|
+
let size = xs.len();
|
|
298
|
+
for (let idx = 0; idx < size; idx++) {
|
|
296
299
|
let item = xs.get(idx);
|
|
297
300
|
result = f(result, item);
|
|
298
301
|
}
|
|
@@ -335,7 +338,8 @@ export let foldl_shortcut = function (xs: CalcitValue, acc: CalcitValue, v0: Cal
|
|
|
335
338
|
}
|
|
336
339
|
if (xs instanceof CalcitList || xs instanceof CalcitSliceList) {
|
|
337
340
|
var state = acc;
|
|
338
|
-
|
|
341
|
+
let size = xs.len();
|
|
342
|
+
for (let idx = 0; idx < size; idx++) {
|
|
339
343
|
let item = xs.get(idx);
|
|
340
344
|
let pair = f(state, item);
|
|
341
345
|
if (pair instanceof CalcitTuple) {
|
package/ts-src/js-map.mts
CHANGED
|
@@ -70,7 +70,8 @@ export class CalcitMap {
|
|
|
70
70
|
let itemsCode = "";
|
|
71
71
|
let pairs = this.pairs();
|
|
72
72
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
73
|
-
let
|
|
73
|
+
let k = pairs[idx][0];
|
|
74
|
+
let v = pairs[idx][1];
|
|
74
75
|
if (shorter) {
|
|
75
76
|
let keyPart = isNestedCalcitData(k) ? tipNestedCalcitData(k) : toString(k, true, disableJsDataWarning);
|
|
76
77
|
let valuePart = isNestedCalcitData(v) ? tipNestedCalcitData(v) : toString(v, true, disableJsDataWarning);
|
|
@@ -177,7 +178,10 @@ export class CalcitMap {
|
|
|
177
178
|
|
|
178
179
|
/** detecthing in custom formatter */
|
|
179
180
|
nestedDataInChildren() {
|
|
180
|
-
|
|
181
|
+
let pairs = this.pairs();
|
|
182
|
+
for (let idx = 0; idx < pairs.length; idx++) {
|
|
183
|
+
let k = pairs[idx][0];
|
|
184
|
+
let v = pairs[idx][1];
|
|
181
185
|
if (!isLiteral(k) || !isLiteral(v)) {
|
|
182
186
|
return true;
|
|
183
187
|
}
|
|
@@ -267,7 +271,8 @@ export class CalcitSliceMap {
|
|
|
267
271
|
let itemsCode = "";
|
|
268
272
|
let pairs = this.pairs();
|
|
269
273
|
for (let idx = 0; idx < pairs.length; idx++) {
|
|
270
|
-
let
|
|
274
|
+
let k = pairs[idx][0];
|
|
275
|
+
let v = pairs[idx][1];
|
|
271
276
|
if (shorter) {
|
|
272
277
|
let keyPart = isNestedCalcitData(k) ? tipNestedCalcitData(k) : toString(k, true, disableJsDataWarning);
|
|
273
278
|
let valuePart = isNestedCalcitData(v) ? tipNestedCalcitData(v) : toString(v, true, disableJsDataWarning);
|
|
@@ -381,7 +386,10 @@ export class CalcitSliceMap {
|
|
|
381
386
|
|
|
382
387
|
/** detecthing in custom formatter */
|
|
383
388
|
nestedDataInChildren() {
|
|
384
|
-
|
|
389
|
+
let pairs = this.pairs();
|
|
390
|
+
for (let idx = 0; idx < pairs.length; idx++) {
|
|
391
|
+
let k = pairs[idx][0];
|
|
392
|
+
let v = pairs[idx][1];
|
|
385
393
|
if (!isLiteral(k) || !isLiteral(v)) {
|
|
386
394
|
return true;
|
|
387
395
|
}
|
package/ts-src/js-record.mts
CHANGED
|
@@ -188,7 +188,8 @@ export let _$n_record_$o_from_map = (proto: CalcitValue, data: CalcitValue): Cal
|
|
|
188
188
|
let pairs_buffer: Array<[CalcitTag, CalcitValue]> = [];
|
|
189
189
|
let pairs = data.pairs();
|
|
190
190
|
for (let i = 0; i < pairs.length; i++) {
|
|
191
|
-
let
|
|
191
|
+
let k = pairs[i][0];
|
|
192
|
+
let v = pairs[i][1];
|
|
192
193
|
pairs_buffer.push([castTag(k), v]);
|
|
193
194
|
}
|
|
194
195
|
// mutable sort
|