@calcit/procs 0.6.0-a1 → 0.6.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/builds/bundle_calcit +0 -0
- package/builds/bundle_calcit_0.6.0 +0 -0
- package/builds/calcit +0 -0
- package/builds/cr +0 -0
- package/builds/cr_0.6.0 +0 -0
- package/lib/calcit-data.mjs +19 -0
- package/lib/calcit.procs.mjs +4 -1
- package/lib/js-cirru.mjs +3 -0
- package/package.json +2 -2
- package/ts-src/calcit-data.mts +19 -0
- package/ts-src/calcit.procs.mts +6 -2
- package/ts-src/js-cirru.mts +3 -0
|
Binary file
|
|
Binary file
|
package/builds/calcit
ADDED
|
Binary file
|
package/builds/cr
ADDED
|
Binary file
|
package/builds/cr_0.6.0
ADDED
|
Binary file
|
package/lib/calcit-data.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
|
|
|
8
8
|
import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
|
|
9
9
|
import { CalcitTuple } from "./js-tuple.mjs";
|
|
10
10
|
import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
|
|
11
|
+
import "@cirru/writer.ts";
|
|
11
12
|
// we have to inject cache in a dirty way in some cases
|
|
12
13
|
const calcit_dirty_hash_key = "_calcit_cached_hash";
|
|
13
14
|
let keywordIdx = 0;
|
|
@@ -166,6 +167,7 @@ let defaultHash_set = valueHash("set:");
|
|
|
166
167
|
let defaultHash_list = valueHash("list:");
|
|
167
168
|
let defaultHash_map = valueHash("map:");
|
|
168
169
|
let defaultHash_record = valueHash("record:");
|
|
170
|
+
let defaultHash_cirru_quote = valueHash("cirru-quote:");
|
|
169
171
|
let defaultHash_unknown = valueHash("unknown:");
|
|
170
172
|
let fnHashCounter = 0;
|
|
171
173
|
let jsObjectHashCounter = 0;
|
|
@@ -280,6 +282,11 @@ export let hashFunction = (x) => {
|
|
|
280
282
|
x.cachedHash = base;
|
|
281
283
|
return base;
|
|
282
284
|
}
|
|
285
|
+
if (x instanceof CalcitCirruQuote) {
|
|
286
|
+
let base = defaultHash_cirru_quote;
|
|
287
|
+
base = hashCirru(base, x.value);
|
|
288
|
+
return base;
|
|
289
|
+
}
|
|
283
290
|
console.warn(`[warn] calcit-js has no method for hashing this: ${x}`);
|
|
284
291
|
// currently we use dirty solution here to generate a custom hash
|
|
285
292
|
// probably happening in .to-pairs of maps, putting a js object into a set
|
|
@@ -290,6 +297,18 @@ export let hashFunction = (x) => {
|
|
|
290
297
|
x[calcit_dirty_hash_key] = hashJsObject;
|
|
291
298
|
return hashJsObject;
|
|
292
299
|
};
|
|
300
|
+
/// traverse Cirru tree to make unique hash
|
|
301
|
+
let hashCirru = (base, x) => {
|
|
302
|
+
if (typeof x === "string") {
|
|
303
|
+
return mergeValueHash(base, hashFunction(x));
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
for (let idx = 0; idx < x.length; idx++) {
|
|
307
|
+
base = mergeValueHash(base, hashCirru(base, x[idx]));
|
|
308
|
+
}
|
|
309
|
+
return base;
|
|
310
|
+
}
|
|
311
|
+
};
|
|
293
312
|
// Dirty code to change ternary-tree behavior
|
|
294
313
|
overwriteHashGenerator(hashFunction);
|
|
295
314
|
export let toString = (x, escaped, disableJsDataWarning = false) => {
|
package/lib/calcit.procs.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
// CALCIT VERSION
|
|
3
|
-
export const calcit_version = "0.6.0
|
|
3
|
+
export const calcit_version = "0.6.0";
|
|
4
4
|
import { parse } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
6
6
|
import "./js-primes.mjs";
|
|
@@ -1322,6 +1322,9 @@ export let _$n_buffer = (...xs) => {
|
|
|
1322
1322
|
export let _$n_hash = (x) => {
|
|
1323
1323
|
return hashFunction(x);
|
|
1324
1324
|
};
|
|
1325
|
+
export let _$n_cirru_quote_$o_to_list = (x) => {
|
|
1326
|
+
return x.toList();
|
|
1327
|
+
};
|
|
1325
1328
|
// special procs have to be defined manually
|
|
1326
1329
|
export let reduce = foldl;
|
|
1327
1330
|
let unavailableProc = (...xs) => {
|
package/lib/js-cirru.mjs
CHANGED
|
@@ -14,6 +14,9 @@ export class CalcitCirruQuote {
|
|
|
14
14
|
toString() {
|
|
15
15
|
return `(cirru-quote ${JSON.stringify(this.value)})`;
|
|
16
16
|
}
|
|
17
|
+
toList() {
|
|
18
|
+
return to_calcit_data(this.value, true);
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
export let format_cirru = (data, useInline) => {
|
|
19
22
|
if (data instanceof CalcitCirruQuote) {
|
package/package.json
CHANGED
package/ts-src/calcit-data.mts
CHANGED
|
@@ -10,6 +10,7 @@ import { CalcitList, CalcitSliceList } from "./js-list.mjs";
|
|
|
10
10
|
import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
|
|
11
11
|
import { CalcitTuple } from "./js-tuple.mjs";
|
|
12
12
|
import { CalcitCirruQuote, cirru_deep_equal } from "./js-cirru.mjs";
|
|
13
|
+
import { CirruWriterNode } from "@cirru/writer.ts";
|
|
13
14
|
|
|
14
15
|
// we have to inject cache in a dirty way in some cases
|
|
15
16
|
const calcit_dirty_hash_key = "_calcit_cached_hash";
|
|
@@ -193,6 +194,7 @@ let defaultHash_set = valueHash("set:");
|
|
|
193
194
|
let defaultHash_list = valueHash("list:");
|
|
194
195
|
let defaultHash_map = valueHash("map:");
|
|
195
196
|
let defaultHash_record = valueHash("record:");
|
|
197
|
+
let defaultHash_cirru_quote = valueHash("cirru-quote:");
|
|
196
198
|
|
|
197
199
|
let defaultHash_unknown = valueHash("unknown:");
|
|
198
200
|
|
|
@@ -312,6 +314,11 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
312
314
|
x.cachedHash = base;
|
|
313
315
|
return base;
|
|
314
316
|
}
|
|
317
|
+
if (x instanceof CalcitCirruQuote) {
|
|
318
|
+
let base = defaultHash_cirru_quote;
|
|
319
|
+
base = hashCirru(base, x.value);
|
|
320
|
+
return base;
|
|
321
|
+
}
|
|
315
322
|
console.warn(`[warn] calcit-js has no method for hashing this: ${x}`);
|
|
316
323
|
// currently we use dirty solution here to generate a custom hash
|
|
317
324
|
// probably happening in .to-pairs of maps, putting a js object into a set
|
|
@@ -323,6 +330,18 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
323
330
|
return hashJsObject;
|
|
324
331
|
};
|
|
325
332
|
|
|
333
|
+
/// traverse Cirru tree to make unique hash
|
|
334
|
+
let hashCirru = (base: number, x: CirruWriterNode) => {
|
|
335
|
+
if (typeof x === "string") {
|
|
336
|
+
return mergeValueHash(base, hashFunction(x));
|
|
337
|
+
} else {
|
|
338
|
+
for (let idx = 0; idx < x.length; idx++) {
|
|
339
|
+
base = mergeValueHash(base, hashCirru(base, x[idx]));
|
|
340
|
+
}
|
|
341
|
+
return base;
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
|
|
326
345
|
// Dirty code to change ternary-tree behavior
|
|
327
346
|
overwriteHashGenerator(hashFunction);
|
|
328
347
|
|
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// CALCIT VERSION
|
|
2
|
-
export const calcit_version = "0.6.0
|
|
2
|
+
export const calcit_version = "0.6.0";
|
|
3
3
|
|
|
4
4
|
import { parse, ICirruNode } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
@@ -37,7 +37,7 @@ import { CalcitList, CalcitSliceList, foldl } from "./js-list.mjs";
|
|
|
37
37
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
38
38
|
import { CalcitSet } from "./js-set.mjs";
|
|
39
39
|
import { CalcitTuple } from "./js-tuple.mjs";
|
|
40
|
-
import { to_calcit_data, extract_cirru_edn } from "./js-cirru.mjs";
|
|
40
|
+
import { to_calcit_data, extract_cirru_edn, CalcitCirruQuote } from "./js-cirru.mjs";
|
|
41
41
|
|
|
42
42
|
let inNodeJs = typeof process !== "undefined" && process?.release?.name === "node";
|
|
43
43
|
|
|
@@ -1419,6 +1419,10 @@ export let _$n_hash = (x: CalcitValue): number => {
|
|
|
1419
1419
|
return hashFunction(x);
|
|
1420
1420
|
};
|
|
1421
1421
|
|
|
1422
|
+
export let _$n_cirru_quote_$o_to_list = (x: CalcitCirruQuote): CalcitValue => {
|
|
1423
|
+
return x.toList();
|
|
1424
|
+
};
|
|
1425
|
+
|
|
1422
1426
|
// special procs have to be defined manually
|
|
1423
1427
|
export let reduce = foldl;
|
|
1424
1428
|
|
package/ts-src/js-cirru.mts
CHANGED
|
@@ -19,6 +19,9 @@ export class CalcitCirruQuote {
|
|
|
19
19
|
toString(): string {
|
|
20
20
|
return `(cirru-quote ${JSON.stringify(this.value)})`;
|
|
21
21
|
}
|
|
22
|
+
toList(): CalcitValue {
|
|
23
|
+
return to_calcit_data(this.value, true);
|
|
24
|
+
}
|
|
22
25
|
}
|
|
23
26
|
|
|
24
27
|
export let format_cirru = (data: CalcitCirruQuote | CalcitList, useInline: boolean): string => {
|