@calcit/ternary-tree 0.0.18 → 0.0.19-a1
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/{hash.d.ts → hash.d.mts} +0 -0
- package/lib/{hash.js → hash.mjs} +0 -0
- package/lib/index.d.mts +4 -0
- package/lib/index.mjs +4 -0
- package/lib/{list.d.ts → list.d.mts} +1 -1
- package/lib/{list.js → list.mjs} +3 -3
- package/lib/main.d.mts +2 -0
- package/lib/{main.js → main.mjs} +6 -6
- package/lib/{map.d.ts → map.d.mts} +1 -1
- package/lib/{map.js → map.mjs} +2 -2
- package/lib/{test-list.d.ts → test-list.d.mts} +0 -0
- package/lib/{test-list.js → test-list.mjs} +18 -2
- package/lib/{test-map.d.ts → test-map.d.mts} +0 -0
- package/lib/{test-map.js → test-map.mjs} +3 -3
- package/lib/{types.d.ts → types.d.mts} +0 -0
- package/lib/{types.js → types.mjs} +0 -0
- package/lib/{utils.d.ts → utils.d.mts} +1 -1
- package/lib/{utils.js → utils.mjs} +2 -2
- package/package.json +9 -7
- package/assets/index.html +0 -2
- package/lib/bundle.js +0 -3022
- package/lib/bundle.js.map +0 -1
- package/lib/index.d.ts +0 -4
- package/lib/index.js +0 -4
- package/lib/main.d.ts +0 -2
- package/src/costs.nim +0 -62
- package/src/hash.ts +0 -78
- package/src/index.ts +0 -5
- package/src/list.ts +0 -996
- package/src/main.ts +0 -20
- package/src/map.ts +0 -1341
- package/src/shape.nim +0 -62
- package/src/test-list.ts +0 -271
- package/src/test-map.ts +0 -288
- package/src/types.ts +0 -87
- package/src/utils.ts +0 -124
File without changes
|
package/lib/{hash.js → hash.mjs}
RENAMED
File without changes
|
package/lib/index.d.mts
ADDED
package/lib/index.mjs
ADDED
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TernaryTreeList } from "./types";
|
1
|
+
import { TernaryTreeList } from "./types.mjs";
|
2
2
|
export declare function getDepth<T>(tree: TernaryTreeList<T>): number;
|
3
3
|
export declare function makeTernaryTreeList<T>(size: number, offset: number, xs: Array<TernaryTreeList<T>>): TernaryTreeList<T>;
|
4
4
|
export declare function initTernaryTreeList<T>(xs: Array<T>): TernaryTreeList<T>;
|
package/lib/{list.js → list.mjs}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { TernaryTreeKind } from "./types";
|
2
|
-
import { dataEqual, divideTernarySizes, roughIntPow } from "./utils";
|
1
|
+
import { TernaryTreeKind } from "./types.mjs";
|
2
|
+
import { dataEqual, divideTernarySizes, roughIntPow } from "./utils.mjs";
|
3
3
|
// just get, will not compute recursively
|
4
4
|
export function getDepth(tree) {
|
5
5
|
if (tree == null)
|
@@ -797,7 +797,7 @@ export function listEqual(xs, ys) {
|
|
797
797
|
return true;
|
798
798
|
}
|
799
799
|
export function checkListStructure(tree) {
|
800
|
-
if (tree == null) {
|
800
|
+
if (tree == null || listLen(tree) === 0) {
|
801
801
|
return true;
|
802
802
|
}
|
803
803
|
else {
|
package/lib/main.d.mts
ADDED
package/lib/{main.js → main.mjs}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { deepEqual, overwriteComparator } from "./utils";
|
2
|
-
import "./test-list";
|
3
|
-
import "./test-map";
|
4
|
-
import { runListTests } from "./test-list";
|
5
|
-
import { runMapTests } from "./test-map";
|
6
|
-
import { mergeValueHash, overwriteHashGenerator, valueHash } from "./types";
|
1
|
+
import { deepEqual, overwriteComparator } from "./utils.mjs";
|
2
|
+
import "./test-list.mjs";
|
3
|
+
import "./test-map.mjs";
|
4
|
+
import { runListTests } from "./test-list.mjs";
|
5
|
+
import { runMapTests } from "./test-map.mjs";
|
6
|
+
import { mergeValueHash, overwriteHashGenerator, valueHash } from "./types.mjs";
|
7
7
|
overwriteComparator((x, y) => {
|
8
8
|
// console.log("comparing", x, y);
|
9
9
|
return deepEqual(x, y);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { TernaryTreeMap, TernaryTreeMapHashEntry } from "./types";
|
1
|
+
import { TernaryTreeMap, TernaryTreeMapHashEntry } from "./types.mjs";
|
2
2
|
export declare function getMapDepth<K, V>(tree: TernaryTreeMap<K, V>): number;
|
3
3
|
export declare function initTernaryTreeMapFromHashEntries<K, T>(xs: Array<TernaryTreeMapHashEntry<K, T>>): TernaryTreeMap<K, T>;
|
4
4
|
export declare function initTernaryTreeMap<K, T>(t: Map<K, T>): TernaryTreeMap<K, T>;
|
package/lib/{map.js → map.mjs}
RENAMED
@@ -1,5 +1,5 @@
|
|
1
|
-
import { TernaryTreeKind, hashGenerator } from "./types";
|
2
|
-
import { divideTernarySizes, cmp, dataEqual } from "./utils";
|
1
|
+
import { TernaryTreeKind, hashGenerator, } from "./types.mjs";
|
2
|
+
import { divideTernarySizes, cmp, dataEqual } from "./utils.mjs";
|
3
3
|
let emptyBranch = null;
|
4
4
|
let nilResult = null;
|
5
5
|
function getMax(tree) {
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { listToString, initTernaryTreeList, initTernaryTreeListFromRange, indexOf, findIndex, reverse, checkListStructure, slice, listToPairs, listToItems, formatListInline, sameListShape, assocBefore, concat, assocAfter, prepend, append, rest, butlast, first, assocList, dissocList, listGet, insert, initEmptyTernaryTreeList, last, listLen, forceListInplaceBalancing, listEqual, indexToItems, listMapValues, } from "./list";
|
2
|
-
import { test, check, arrayEqual, checkEqual } from "./utils";
|
1
|
+
import { listToString, initTernaryTreeList, initTernaryTreeListFromRange, indexOf, findIndex, reverse, checkListStructure, slice, listToPairs, listToItems, formatListInline, sameListShape, assocBefore, concat, assocAfter, prepend, append, rest, butlast, first, assocList, dissocList, listGet, insert, initEmptyTernaryTreeList, last, listLen, forceListInplaceBalancing, listEqual, indexToItems, listMapValues, } from "./list.mjs";
|
2
|
+
import { test, check, arrayEqual, checkEqual } from "./utils.mjs";
|
3
3
|
export let runListTests = () => {
|
4
4
|
test("init list", () => {
|
5
5
|
check(listToString(initTernaryTreeList([1, 2, 3, 4])) === "TernaryTreeList[4, ...]");
|
@@ -89,6 +89,9 @@ export let runListTests = () => {
|
|
89
89
|
let data4 = initTernaryTreeList(origin4);
|
90
90
|
let data4n = initTernaryTreeList(origin4);
|
91
91
|
let data4Made = prepend(initTernaryTreeList([2, 3, 4]), 1);
|
92
|
+
checkListStructure(data4);
|
93
|
+
checkListStructure(data4n);
|
94
|
+
checkListStructure(data4Made);
|
92
95
|
check(sameListShape(data4, data4) === true);
|
93
96
|
check(sameListShape(data4, data4n) === true);
|
94
97
|
check(sameListShape(data4, data4Made) === false);
|
@@ -101,6 +104,7 @@ export let runListTests = () => {
|
|
101
104
|
var data = initTernaryTreeList([]);
|
102
105
|
for (let idx = 0; idx < 20; idx++) {
|
103
106
|
data = append(data, idx, true);
|
107
|
+
checkListStructure(data);
|
104
108
|
}
|
105
109
|
// echo data.formatInline
|
106
110
|
check(formatListInline(data) === "(((0 1 2) (3 4 5) (6 7 8)) ((9 10 11) (12 13 14) (15 16 17)) (18 19 _))");
|
@@ -111,6 +115,7 @@ export let runListTests = () => {
|
|
111
115
|
test("iterator", () => {
|
112
116
|
let origin4 = [1, 2, 3, 4];
|
113
117
|
let data4 = initTernaryTreeList(origin4);
|
118
|
+
checkListStructure(data4);
|
114
119
|
var i = 0;
|
115
120
|
for (let item of listToItems(data4)) {
|
116
121
|
i = i + 1;
|
@@ -126,11 +131,18 @@ export let runListTests = () => {
|
|
126
131
|
var data = initTernaryTreeList([]);
|
127
132
|
for (let idx = 0; idx < 20; idx++) {
|
128
133
|
data = append(data, idx, true);
|
134
|
+
checkListStructure(data);
|
129
135
|
}
|
130
136
|
check(checkListStructure(data));
|
137
|
+
for (let idx = 0; idx < 20; idx++) {
|
138
|
+
data = rest(data);
|
139
|
+
checkListStructure(data);
|
140
|
+
}
|
131
141
|
let origin11 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
|
132
142
|
let data11 = initTernaryTreeList(origin11);
|
133
143
|
check(checkListStructure(data11));
|
144
|
+
checkListStructure(prepend(initEmptyTernaryTreeList(), 1));
|
145
|
+
checkListStructure(prepend(null, 1));
|
134
146
|
});
|
135
147
|
test("slices", () => {
|
136
148
|
var data = initTernaryTreeList([]);
|
@@ -144,6 +156,7 @@ export let runListTests = () => {
|
|
144
156
|
for (let i = 0; i < 40; i++) {
|
145
157
|
for (let j = i; j < 40; j++) {
|
146
158
|
check(arrayEqual([...listToItems(slice(data, i, j))], list40.slice(i, j)));
|
159
|
+
checkListStructure(slice(data, i, j));
|
147
160
|
}
|
148
161
|
}
|
149
162
|
});
|
@@ -156,6 +169,7 @@ export let runListTests = () => {
|
|
156
169
|
test("list traverse", () => {
|
157
170
|
var i = 0;
|
158
171
|
let data = initTernaryTreeList([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
|
172
|
+
checkListStructure(data);
|
159
173
|
for (let x of listToItems(data)) {
|
160
174
|
i = i + 1;
|
161
175
|
}
|
@@ -180,5 +194,7 @@ export let runListTests = () => {
|
|
180
194
|
let data1 = initTernaryTreeList([3, 4]);
|
181
195
|
let data2 = initTernaryTreeListFromRange([1, 2, 3, 4, 5, 6], 2, 4);
|
182
196
|
check(listEqual(data1, data2));
|
197
|
+
checkListStructure(data1);
|
198
|
+
checkListStructure(data2);
|
183
199
|
});
|
184
200
|
};
|
File without changes
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { hashGenerator } from "./types";
|
2
|
-
import { test, check, cmp, deepEqual, justDisplay } from "./utils";
|
3
|
-
import { initTernaryTreeMap, initTernaryTreeMapFromArray, toHashSortedPairs, merge, mergeSkip, formatMapInline, assocMap, dissocMap, contains, toPairs, initEmptyTernaryTreeMap, sameMapShape, checkMapStructure, mapLen, mapEqual, toKeys, toPairsArray, mapMapValues, mapGetDefault, } from "./map";
|
1
|
+
import { hashGenerator } from "./types.mjs";
|
2
|
+
import { test, check, cmp, deepEqual, justDisplay } from "./utils.mjs";
|
3
|
+
import { initTernaryTreeMap, initTernaryTreeMapFromArray, toHashSortedPairs, merge, mergeSkip, formatMapInline, assocMap, dissocMap, contains, toPairs, initEmptyTernaryTreeMap, sameMapShape, checkMapStructure, mapLen, mapEqual, toKeys, toPairsArray, mapMapValues, mapGetDefault, } from "./map.mjs";
|
4
4
|
export let runMapTests = () => {
|
5
5
|
test("init map", () => {
|
6
6
|
var dict = new Map();
|
File without changes
|
File without changes
|
@@ -17,4 +17,4 @@ export declare let checkEqual: (x: any, y: any) => void;
|
|
17
17
|
export declare let justDisplay: (x: any, y: any) => void;
|
18
18
|
export declare let cmp: (x: any, y: any) => 0 | 1 | -1;
|
19
19
|
export declare let deepEqual: (x: any, y: any) => boolean;
|
20
|
-
export declare
|
20
|
+
export declare function arrayEqual<T>(xs: Array<T>, ys: Array<T>): boolean;
|
@@ -101,7 +101,7 @@ export let deepEqual = function (x, y) {
|
|
101
101
|
else
|
102
102
|
return false;
|
103
103
|
};
|
104
|
-
export
|
104
|
+
export function arrayEqual(xs, ys) {
|
105
105
|
if (xs.length != ys.length) {
|
106
106
|
return false;
|
107
107
|
}
|
@@ -111,4 +111,4 @@ export let arrayEqual = (xs, ys) => {
|
|
111
111
|
}
|
112
112
|
}
|
113
113
|
return true;
|
114
|
-
}
|
114
|
+
}
|
package/package.json
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@calcit/ternary-tree",
|
3
|
-
"version": "0.0.
|
4
|
-
"main": "./lib/index.
|
3
|
+
"version": "0.0.19-a1",
|
4
|
+
"main": "./lib/index.mjs",
|
5
|
+
"scripts": {
|
6
|
+
"bundle": "esbuild src/main.mts --bundle --outfile=lib/bundle.js --platform=node --resolve-extensions=.mjs,.mts,.ts,.js"
|
7
|
+
},
|
5
8
|
"devDependencies": {
|
6
|
-
"
|
7
|
-
"
|
8
|
-
"
|
9
|
-
"
|
10
|
-
"webpack-cli": "^4.9.1"
|
9
|
+
"esbuild": "^0.14.27",
|
10
|
+
"prettier": "^2.6.0",
|
11
|
+
"typescript": "^4.6.2",
|
12
|
+
"vite": "^2.8.6"
|
11
13
|
}
|
12
14
|
}
|
package/assets/index.html
DELETED