@thi.ng/zipper 2.1.100 → 2.1.102
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/CHANGELOG.md +8 -1
- package/README.md +1 -1
- package/package.json +11 -11
- package/zipper.d.ts +1 -1
- package/zipper.js +26 -37
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-06-21T19:34:38Z
|
|
4
4
|
- **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
|
|
5
5
|
|
|
6
6
|
All notable changes to this project will be documented in this file.
|
|
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
|
|
|
9
9
|
**Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
|
|
10
10
|
and/or version bumps of transitive dependencies.
|
|
11
11
|
|
|
12
|
+
### [2.1.102](https://github.com/thi-ng/umbrella/tree/@thi.ng/zipper@2.1.102) (2024-06-21)
|
|
13
|
+
|
|
14
|
+
#### ♻️ Refactoring
|
|
15
|
+
|
|
16
|
+
- rename various rest args to be more semantically meaningful ([8088a56](https://github.com/thi-ng/umbrella/commit/8088a56))
|
|
17
|
+
- enforce uniform naming convention of internal functions ([56992b2](https://github.com/thi-ng/umbrella/commit/56992b2))
|
|
18
|
+
|
|
12
19
|
### [2.1.99](https://github.com/thi-ng/umbrella/tree/@thi.ng/zipper@2.1.99) (2024-04-20)
|
|
13
20
|
|
|
14
21
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
[](https://mastodon.thi.ng/@toxi)
|
|
8
8
|
|
|
9
9
|
> [!NOTE]
|
|
10
|
-
> This is one of
|
|
10
|
+
> This is one of 193 standalone projects, maintained as part
|
|
11
11
|
> of the [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo
|
|
12
12
|
> and anti-framework.
|
|
13
13
|
>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/zipper",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.102",
|
|
4
4
|
"description": "Functional tree editing, manipulation & navigation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "https://github.com/thi-ng/umbrella.git"
|
|
12
12
|
},
|
|
13
|
-
"homepage": "https://
|
|
13
|
+
"homepage": "https://thi.ng/zipper",
|
|
14
14
|
"funding": [
|
|
15
15
|
{
|
|
16
16
|
"type": "github",
|
|
@@ -36,16 +36,16 @@
|
|
|
36
36
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@thi.ng/api": "^8.11.
|
|
40
|
-
"@thi.ng/arrays": "^2.9.
|
|
41
|
-
"@thi.ng/checks": "^3.6.
|
|
42
|
-
"@thi.ng/errors": "^2.5.
|
|
39
|
+
"@thi.ng/api": "^8.11.3",
|
|
40
|
+
"@thi.ng/arrays": "^2.9.7",
|
|
41
|
+
"@thi.ng/checks": "^3.6.5",
|
|
42
|
+
"@thi.ng/errors": "^2.5.8"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@microsoft/api-extractor": "^7.
|
|
46
|
-
"esbuild": "^0.
|
|
47
|
-
"typedoc": "^0.25.
|
|
48
|
-
"typescript": "^5.
|
|
45
|
+
"@microsoft/api-extractor": "^7.47.0",
|
|
46
|
+
"esbuild": "^0.21.5",
|
|
47
|
+
"typedoc": "^0.25.13",
|
|
48
|
+
"typescript": "^5.5.2"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"adjacency",
|
|
@@ -94,5 +94,5 @@
|
|
|
94
94
|
],
|
|
95
95
|
"year": 2015
|
|
96
96
|
},
|
|
97
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "154c95cf9d6bab32174498ec3b5b5d87e42be7f9\n"
|
|
98
98
|
}
|
package/zipper.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export declare class Location<T> {
|
|
|
24
24
|
get prev(): Maybe<Location<T>>;
|
|
25
25
|
get next(): Maybe<Location<T>>;
|
|
26
26
|
replace(x: T): Location<T>;
|
|
27
|
-
update(fn: FnO<T, T>, ...
|
|
27
|
+
update(fn: FnO<T, T>, ...args: any[]): Location<T>;
|
|
28
28
|
insertLeft(x: T): Location<T>;
|
|
29
29
|
insertRight(x: T): Location<T>;
|
|
30
30
|
insertChild(x: T): Location<T>;
|
package/zipper.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { peek } from "@thi.ng/arrays/peek";
|
|
2
2
|
import { isArray } from "@thi.ng/checks/is-array";
|
|
3
3
|
import { assert } from "@thi.ng/errors/assert";
|
|
4
|
-
const
|
|
4
|
+
const __newPath = (l, r, path, nodes, changed = false) => ({
|
|
5
5
|
l,
|
|
6
6
|
r,
|
|
7
7
|
path,
|
|
8
8
|
nodes,
|
|
9
9
|
changed
|
|
10
10
|
});
|
|
11
|
-
const
|
|
11
|
+
const __changedPath = (path) => path ? { ...path, changed: true } : void 0;
|
|
12
12
|
class Location {
|
|
13
13
|
_node;
|
|
14
14
|
_ops;
|
|
@@ -57,7 +57,7 @@ class Location {
|
|
|
57
57
|
return lefts && lefts.length ? new Location(
|
|
58
58
|
peek(lefts),
|
|
59
59
|
this._ops,
|
|
60
|
-
|
|
60
|
+
__newPath(
|
|
61
61
|
lefts.slice(0, lefts.length - 1),
|
|
62
62
|
[this._node].concat(path.r || []),
|
|
63
63
|
path.path,
|
|
@@ -69,13 +69,12 @@ class Location {
|
|
|
69
69
|
get right() {
|
|
70
70
|
const path = this._path;
|
|
71
71
|
const rights = path && path.r;
|
|
72
|
-
if (!rights)
|
|
73
|
-
return;
|
|
72
|
+
if (!rights) return;
|
|
74
73
|
const r = rights.slice(1);
|
|
75
74
|
return new Location(
|
|
76
75
|
rights[0],
|
|
77
76
|
this._ops,
|
|
78
|
-
|
|
77
|
+
__newPath(
|
|
79
78
|
(path.l || []).concat([this._node]),
|
|
80
79
|
r.length ? r : void 0,
|
|
81
80
|
path.path,
|
|
@@ -90,7 +89,7 @@ class Location {
|
|
|
90
89
|
return lefts && lefts.length ? new Location(
|
|
91
90
|
lefts[0],
|
|
92
91
|
this._ops,
|
|
93
|
-
|
|
92
|
+
__newPath(
|
|
94
93
|
void 0,
|
|
95
94
|
lefts.slice(1).concat([this._node], path.r || []),
|
|
96
95
|
path.path,
|
|
@@ -105,7 +104,7 @@ class Location {
|
|
|
105
104
|
return rights ? new Location(
|
|
106
105
|
peek(rights),
|
|
107
106
|
this._ops,
|
|
108
|
-
|
|
107
|
+
__newPath(
|
|
109
108
|
(path.l || []).concat(
|
|
110
109
|
[this._node],
|
|
111
110
|
rights.slice(0, rights.length - 1)
|
|
@@ -118,17 +117,15 @@ class Location {
|
|
|
118
117
|
) : this;
|
|
119
118
|
}
|
|
120
119
|
get down() {
|
|
121
|
-
if (!this.isBranch)
|
|
122
|
-
return;
|
|
120
|
+
if (!this.isBranch) return;
|
|
123
121
|
const children = this.children;
|
|
124
|
-
if (!children)
|
|
125
|
-
return;
|
|
122
|
+
if (!children) return;
|
|
126
123
|
const path = this._path;
|
|
127
124
|
const r = children.slice(1);
|
|
128
125
|
return new Location(
|
|
129
126
|
children[0],
|
|
130
127
|
this._ops,
|
|
131
|
-
|
|
128
|
+
__newPath(
|
|
132
129
|
void 0,
|
|
133
130
|
r.length ? r : void 0,
|
|
134
131
|
path,
|
|
@@ -139,8 +136,7 @@ class Location {
|
|
|
139
136
|
get up() {
|
|
140
137
|
let path = this._path;
|
|
141
138
|
const pnodes = path && path.nodes;
|
|
142
|
-
if (!pnodes)
|
|
143
|
-
return;
|
|
139
|
+
if (!pnodes) return;
|
|
144
140
|
const pnode = peek(pnodes);
|
|
145
141
|
if (path.changed) {
|
|
146
142
|
return new Location(
|
|
@@ -149,7 +145,7 @@ class Location {
|
|
|
149
145
|
(path.l || []).concat([this._node], path.r || [])
|
|
150
146
|
),
|
|
151
147
|
this._ops,
|
|
152
|
-
|
|
148
|
+
__changedPath(path.path)
|
|
153
149
|
);
|
|
154
150
|
} else {
|
|
155
151
|
return new Location(pnode, this._ops, path.path);
|
|
@@ -161,37 +157,31 @@ class Location {
|
|
|
161
157
|
}
|
|
162
158
|
get prev() {
|
|
163
159
|
let node = this.left;
|
|
164
|
-
if (!node)
|
|
165
|
-
return this.up;
|
|
160
|
+
if (!node) return this.up;
|
|
166
161
|
while (true) {
|
|
167
162
|
const child = node.isBranch ? node.down : void 0;
|
|
168
|
-
if (!child)
|
|
169
|
-
return node;
|
|
163
|
+
if (!child) return node;
|
|
170
164
|
node = child.rightmost;
|
|
171
165
|
}
|
|
172
166
|
}
|
|
173
167
|
get next() {
|
|
174
|
-
if (this.isBranch)
|
|
175
|
-
return this.down;
|
|
168
|
+
if (this.isBranch) return this.down;
|
|
176
169
|
let right = this.right;
|
|
177
|
-
if (right)
|
|
178
|
-
return right;
|
|
170
|
+
if (right) return right;
|
|
179
171
|
let loc = this;
|
|
180
172
|
while (true) {
|
|
181
173
|
const up = loc.up;
|
|
182
|
-
if (!up)
|
|
183
|
-
return;
|
|
174
|
+
if (!up) return;
|
|
184
175
|
right = up.right;
|
|
185
|
-
if (right)
|
|
186
|
-
return right;
|
|
176
|
+
if (right) return right;
|
|
187
177
|
loc = up;
|
|
188
178
|
}
|
|
189
179
|
}
|
|
190
180
|
replace(x) {
|
|
191
|
-
return new Location(x, this._ops,
|
|
181
|
+
return new Location(x, this._ops, __changedPath(this._path));
|
|
192
182
|
}
|
|
193
|
-
update(fn, ...
|
|
194
|
-
return this.replace(fn(this._node, ...
|
|
183
|
+
update(fn, ...args) {
|
|
184
|
+
return this.replace(fn(this._node, ...args));
|
|
195
185
|
}
|
|
196
186
|
insertLeft(x) {
|
|
197
187
|
this.ensureNotRoot();
|
|
@@ -199,7 +189,7 @@ class Location {
|
|
|
199
189
|
return new Location(
|
|
200
190
|
this._node,
|
|
201
191
|
this._ops,
|
|
202
|
-
|
|
192
|
+
__newPath(
|
|
203
193
|
path.l ? path.l.concat([x]) : [x],
|
|
204
194
|
path.r,
|
|
205
195
|
path.path,
|
|
@@ -214,7 +204,7 @@ class Location {
|
|
|
214
204
|
return new Location(
|
|
215
205
|
this._node,
|
|
216
206
|
this._ops,
|
|
217
|
-
|
|
207
|
+
__newPath(
|
|
218
208
|
path.l,
|
|
219
209
|
[x].concat(path.r || []),
|
|
220
210
|
path.path,
|
|
@@ -241,7 +231,7 @@ class Location {
|
|
|
241
231
|
let loc = new Location(
|
|
242
232
|
peek(lefts),
|
|
243
233
|
this._ops,
|
|
244
|
-
|
|
234
|
+
__newPath(
|
|
245
235
|
lefts.slice(0, lefts.length - 1),
|
|
246
236
|
path.r,
|
|
247
237
|
path.path,
|
|
@@ -251,15 +241,14 @@ class Location {
|
|
|
251
241
|
);
|
|
252
242
|
while (true) {
|
|
253
243
|
const child = loc.isBranch ? loc.down : void 0;
|
|
254
|
-
if (!child)
|
|
255
|
-
return loc;
|
|
244
|
+
if (!child) return loc;
|
|
256
245
|
loc = child.rightmost;
|
|
257
246
|
}
|
|
258
247
|
}
|
|
259
248
|
return new Location(
|
|
260
249
|
this.newNode(peek(path.nodes), path.r || []),
|
|
261
250
|
this._ops,
|
|
262
|
-
|
|
251
|
+
__changedPath(path.path)
|
|
263
252
|
);
|
|
264
253
|
}
|
|
265
254
|
newNode(node, children) {
|