@calcit/procs 0.5.36 → 0.5.39
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 +9 -4
- package/lib/calcit.procs.mjs +8 -5
- package/package.json +2 -2
- package/ts-src/calcit-data.mts +10 -4
- package/ts-src/calcit.procs.mts +8 -5
package/lib/calcit-data.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { overwriteComparator } from "@calcit/ternary-tree";
|
|
|
3
3
|
import { overwriteMapComparator } from "./js-map.mjs";
|
|
4
4
|
import { CalcitRecord, fieldsEqual } from "./js-record.mjs";
|
|
5
5
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
6
|
-
import "./js-primes.mjs";
|
|
6
|
+
import { _$n_compare } from "./js-primes.mjs";
|
|
7
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";
|
|
@@ -220,9 +220,10 @@ export let hashFunction = (x) => {
|
|
|
220
220
|
return base;
|
|
221
221
|
}
|
|
222
222
|
if (x instanceof CalcitSet) {
|
|
223
|
-
// TODO not using dirty solution for code
|
|
224
223
|
let base = defaultHash_set;
|
|
225
224
|
let values = x.values();
|
|
225
|
+
// sort elements for stable hash result
|
|
226
|
+
values.sort((a, b) => _$n_compare(a, b));
|
|
226
227
|
for (let idx = 0; idx < values.length; idx++) {
|
|
227
228
|
let item = values[idx];
|
|
228
229
|
base = mergeValueHash(base, hashFunction(item));
|
|
@@ -249,7 +250,9 @@ export let hashFunction = (x) => {
|
|
|
249
250
|
}
|
|
250
251
|
if (x instanceof CalcitSliceMap) {
|
|
251
252
|
let base = defaultHash_map;
|
|
252
|
-
|
|
253
|
+
let pairs = x.pairs();
|
|
254
|
+
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
255
|
+
for (let [k, v] of pairs) {
|
|
253
256
|
base = mergeValueHash(base, hashFunction(k));
|
|
254
257
|
base = mergeValueHash(base, hashFunction(v));
|
|
255
258
|
}
|
|
@@ -258,7 +261,9 @@ export let hashFunction = (x) => {
|
|
|
258
261
|
}
|
|
259
262
|
if (x instanceof CalcitMap) {
|
|
260
263
|
let base = defaultHash_map;
|
|
261
|
-
|
|
264
|
+
let pairs = x.pairs();
|
|
265
|
+
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
266
|
+
for (let [k, v] of pairs) {
|
|
262
267
|
base = mergeValueHash(base, hashFunction(k));
|
|
263
268
|
base = mergeValueHash(base, hashFunction(v));
|
|
264
269
|
}
|
package/lib/calcit.procs.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var _a;
|
|
2
2
|
// CALCIT VERSION
|
|
3
|
-
export const calcit_version = "0.5.
|
|
3
|
+
export const calcit_version = "0.5.39";
|
|
4
4
|
import { parse } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
6
6
|
import "./js-primes.mjs";
|
|
@@ -848,7 +848,7 @@ export let aget = (x, name) => {
|
|
|
848
848
|
export let aset = (x, name, v) => {
|
|
849
849
|
return (x[name] = v);
|
|
850
850
|
};
|
|
851
|
-
export let get_env = (name) => {
|
|
851
|
+
export let get_env = (name, v0) => {
|
|
852
852
|
let v = undefined;
|
|
853
853
|
if (inNodeJs) {
|
|
854
854
|
// only available for Node.js
|
|
@@ -857,10 +857,13 @@ export let get_env = (name) => {
|
|
|
857
857
|
else if (typeof URLSearchParams != null && typeof location != null) {
|
|
858
858
|
v = new URLSearchParams(location.search).get(name);
|
|
859
859
|
}
|
|
860
|
-
if (v
|
|
861
|
-
console.
|
|
860
|
+
if (v != null && v0 != null) {
|
|
861
|
+
console.log(`(get-env ${name}): ${v}`);
|
|
862
862
|
}
|
|
863
|
-
|
|
863
|
+
if (v == null && v0 == null) {
|
|
864
|
+
console.warn(`(get-env "${name}"): config not found`);
|
|
865
|
+
}
|
|
866
|
+
return v !== null && v !== void 0 ? v : v0;
|
|
864
867
|
};
|
|
865
868
|
export let turn_keyword = (x) => {
|
|
866
869
|
if (typeof x === "string") {
|
package/package.json
CHANGED
package/ts-src/calcit-data.mts
CHANGED
|
@@ -5,7 +5,7 @@ import { overwriteMapComparator } from "./js-map.mjs";
|
|
|
5
5
|
import { CalcitRecord, fieldsEqual } from "./js-record.mjs";
|
|
6
6
|
import { CalcitMap, CalcitSliceMap } from "./js-map.mjs";
|
|
7
7
|
|
|
8
|
-
import { CalcitValue } from "./js-primes.mjs";
|
|
8
|
+
import { CalcitValue, _$n_compare } from "./js-primes.mjs";
|
|
9
9
|
import { CalcitList, CalcitSliceList } from "./js-list.mjs";
|
|
10
10
|
import { CalcitSet, overwriteSetComparator } from "./js-set.mjs";
|
|
11
11
|
import { CalcitTuple } from "./js-tuple.mjs";
|
|
@@ -251,9 +251,10 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
251
251
|
return base;
|
|
252
252
|
}
|
|
253
253
|
if (x instanceof CalcitSet) {
|
|
254
|
-
// TODO not using dirty solution for code
|
|
255
254
|
let base = defaultHash_set;
|
|
256
255
|
let values = x.values();
|
|
256
|
+
// sort elements for stable hash result
|
|
257
|
+
values.sort((a, b) => _$n_compare(a, b));
|
|
257
258
|
for (let idx = 0; idx < values.length; idx++) {
|
|
258
259
|
let item = values[idx];
|
|
259
260
|
base = mergeValueHash(base, hashFunction(item));
|
|
@@ -280,7 +281,9 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
280
281
|
}
|
|
281
282
|
if (x instanceof CalcitSliceMap) {
|
|
282
283
|
let base = defaultHash_map;
|
|
283
|
-
|
|
284
|
+
let pairs = x.pairs();
|
|
285
|
+
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
286
|
+
for (let [k, v] of pairs) {
|
|
284
287
|
base = mergeValueHash(base, hashFunction(k));
|
|
285
288
|
base = mergeValueHash(base, hashFunction(v));
|
|
286
289
|
}
|
|
@@ -289,7 +292,10 @@ export let hashFunction = (x: CalcitValue): Hash => {
|
|
|
289
292
|
}
|
|
290
293
|
if (x instanceof CalcitMap) {
|
|
291
294
|
let base = defaultHash_map;
|
|
292
|
-
|
|
295
|
+
|
|
296
|
+
let pairs = x.pairs();
|
|
297
|
+
pairs.sort((a, b) => _$n_compare(a[0], b[0]));
|
|
298
|
+
for (let [k, v] of pairs) {
|
|
293
299
|
base = mergeValueHash(base, hashFunction(k));
|
|
294
300
|
base = mergeValueHash(base, hashFunction(v));
|
|
295
301
|
}
|
package/ts-src/calcit.procs.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// CALCIT VERSION
|
|
2
|
-
export const calcit_version = "0.5.
|
|
2
|
+
export const calcit_version = "0.5.39";
|
|
3
3
|
|
|
4
4
|
import { parse, ICirruNode } from "@cirru/parser.ts";
|
|
5
5
|
import { writeCirruCode } from "@cirru/writer.ts";
|
|
@@ -935,7 +935,7 @@ export let aset = (x: any, name: string, v: any): any => {
|
|
|
935
935
|
return (x[name] = v);
|
|
936
936
|
};
|
|
937
937
|
|
|
938
|
-
export let get_env = (name: string): string => {
|
|
938
|
+
export let get_env = (name: string, v0: string): string => {
|
|
939
939
|
let v = undefined;
|
|
940
940
|
if (inNodeJs) {
|
|
941
941
|
// only available for Node.js
|
|
@@ -943,10 +943,13 @@ export let get_env = (name: string): string => {
|
|
|
943
943
|
} else if (typeof URLSearchParams != null && typeof location != null) {
|
|
944
944
|
v = new URLSearchParams(location.search).get(name);
|
|
945
945
|
}
|
|
946
|
-
if (v
|
|
947
|
-
console.
|
|
946
|
+
if (v != null && v0 != null) {
|
|
947
|
+
console.log(`(get-env ${name}): ${v}`);
|
|
948
948
|
}
|
|
949
|
-
|
|
949
|
+
if (v == null && v0 == null) {
|
|
950
|
+
console.warn(`(get-env "${name}"): config not found`);
|
|
951
|
+
}
|
|
952
|
+
return v ?? v0;
|
|
950
953
|
};
|
|
951
954
|
|
|
952
955
|
export let turn_keyword = (x: CalcitValue): CalcitKeyword => {
|