@calcit/procs 0.5.38 → 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 +1 -1
- package/package.json +2 -2
- package/ts-src/calcit-data.mts +10 -4
- package/ts-src/calcit.procs.mts +1 -1
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
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