flo-mat 3.0.13 → 3.0.14
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/browser/index.js +14 -10
- package/browser/index.min.js +1 -1
- package/node/cp-node/fs/clone.d.ts +1 -1
- package/node/cp-node/fs/clone.js +14 -10
- package/node/cp-node/fs/clone.js.map +1 -1
- package/node/cp-node/fs/get-all-on-loop.js.map +1 -1
- package/package.json +1 -1
- package/src/cp-node/fs/clone.ts +20 -14
- package/src/cp-node/fs/get-all-on-loop.ts +1 -1
package/node/cp-node/fs/clone.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** @internal */
|
|
2
|
-
const EDGES = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
2
|
+
const EDGES = ['prev', 'next', 'prevOnCircle', 'nextOnCircle', 'holeCloserTwin'];
|
|
3
3
|
/**
|
|
4
4
|
* Returns a deep clone of this `CpNode`. Can be used to copy the MAT
|
|
5
5
|
* since cloning a single `CpNode` necessarily implies cloning all
|
|
@@ -9,32 +9,36 @@ function clone(cpNode) {
|
|
|
9
9
|
// Don't change this function to be recursive, the call stack may
|
|
10
10
|
// overflow if there are too many CpNodes.
|
|
11
11
|
const nodeMap = new Map();
|
|
12
|
-
const newCpNode =
|
|
12
|
+
const newCpNode = cloneWithoutEdges(cpNode);
|
|
13
13
|
nodeMap.set(cpNode, newCpNode);
|
|
14
14
|
const cpStack = [{ cpNode, newCpNode }];
|
|
15
15
|
while (cpStack.length) {
|
|
16
16
|
const { cpNode, newCpNode } = cpStack.pop();
|
|
17
17
|
for (const edge of EDGES) {
|
|
18
18
|
const node = cpNode[edge];
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
newNode = cloneWithoutLinks(node);
|
|
22
|
-
nodeMap.set(node, newNode);
|
|
23
|
-
cpStack.push({ cpNode: node, newCpNode: newNode });
|
|
19
|
+
if (node === undefined) {
|
|
20
|
+
continue;
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
let node_ = nodeMap.get(node);
|
|
23
|
+
if (!node_) {
|
|
24
|
+
node_ = cloneWithoutEdges(node);
|
|
25
|
+
nodeMap.set(node, node_);
|
|
26
|
+
cpStack.push({ cpNode: node, newCpNode: node_ });
|
|
27
|
+
}
|
|
28
|
+
newCpNode[edge] = node_;
|
|
26
29
|
}
|
|
27
30
|
}
|
|
28
31
|
return newCpNode;
|
|
29
32
|
}
|
|
30
|
-
function
|
|
33
|
+
function cloneWithoutEdges(cpNode) {
|
|
31
34
|
const newNode = {
|
|
32
35
|
...cpNode,
|
|
33
36
|
...{
|
|
34
37
|
prev: undefined,
|
|
35
38
|
next: undefined,
|
|
36
39
|
prevOnCircle: undefined,
|
|
37
|
-
nextOnCircle: undefined
|
|
40
|
+
nextOnCircle: undefined,
|
|
41
|
+
holeCloserTwin: undefined
|
|
38
42
|
}
|
|
39
43
|
};
|
|
40
44
|
return newNode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/cp-node/fs/clone.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/cp-node/fs/clone.ts"],"names":[],"mappings":"AAWA,gBAAgB;AAChB,MAAM,KAAK,GAAW,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,CAAC,CAAC;AAOzF;;;;GAIG;AACH,SAAS,KAAK,CACN,MAAc;IAElB,kEAAkE;IAClE,0CAA0C;IAE1C,MAAM,OAAO,GAAoC,IAAI,GAAG,EAAE,CAAC;IAE3D,MAAM,SAAS,GAAuB,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAEhE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC/B,MAAM,OAAO,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC,CAAC;IAExC,OAAO,OAAO,CAAC,MAAM,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"get-all-on-loop.js","sourceRoot":"","sources":["../../../src/cp-node/fs/get-all-on-loop.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,SAAS,YAAY,CACb,MAAc;IAElB,MAAM,OAAO,GAAG,MAAM,CAAC;IACvB,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;IAC1B,IAAI,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC;IAE1B,OAAO,OAAO,KAAK,OAAO,EAAE,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACtB,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;IAC3B,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAGD,OAAO,EAAE,YAAY,EAAE,CAAA"}
|
package/package.json
CHANGED
package/src/cp-node/fs/clone.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CpNode } from "../cp-node.js";
|
|
1
|
+
import type { CpNode } from "../cp-node.js";
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
/** @internal */
|
|
@@ -6,14 +6,15 @@ type Edge =
|
|
|
6
6
|
| 'prev'
|
|
7
7
|
| 'next'
|
|
8
8
|
| 'prevOnCircle'
|
|
9
|
-
| 'nextOnCircle'
|
|
9
|
+
| 'nextOnCircle'
|
|
10
|
+
| 'holeCloserTwin';
|
|
10
11
|
|
|
11
12
|
/** @internal */
|
|
12
|
-
const EDGES: Edge[] = ['prev', 'next', 'prevOnCircle', 'nextOnCircle'];
|
|
13
|
+
const EDGES: Edge[] = ['prev', 'next', 'prevOnCircle', 'nextOnCircle', 'holeCloserTwin'];
|
|
13
14
|
|
|
14
15
|
|
|
15
16
|
type CpNodeWithoutEdges =
|
|
16
|
-
Omit<CpNode, 'prev' | 'next' | 'prevOnCircle' | 'nextOnCircle'>;
|
|
17
|
+
Omit<CpNode, 'prev' | 'next' | 'prevOnCircle' | 'nextOnCircle' | 'holeCloserTwin'>;
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
/**
|
|
@@ -21,13 +22,15 @@ type CpNodeWithoutEdges =
|
|
|
21
22
|
* since cloning a single `CpNode` necessarily implies cloning all
|
|
22
23
|
* `CpNode`s on the same MAT tree.
|
|
23
24
|
*/
|
|
24
|
-
function clone(
|
|
25
|
+
function clone(
|
|
26
|
+
cpNode: CpNode): CpNode {
|
|
27
|
+
|
|
25
28
|
// Don't change this function to be recursive, the call stack may
|
|
26
29
|
// overflow if there are too many CpNodes.
|
|
27
30
|
|
|
28
31
|
const nodeMap: Map<CpNode, CpNodeWithoutEdges> = new Map();
|
|
29
32
|
|
|
30
|
-
const newCpNode: CpNodeWithoutEdges =
|
|
33
|
+
const newCpNode: CpNodeWithoutEdges = cloneWithoutEdges(cpNode);
|
|
31
34
|
|
|
32
35
|
nodeMap.set(cpNode, newCpNode);
|
|
33
36
|
const cpStack = [{ cpNode, newCpNode }];
|
|
@@ -37,14 +40,16 @@ function clone(cpNode: CpNode): CpNode {
|
|
|
37
40
|
|
|
38
41
|
for (const edge of EDGES) {
|
|
39
42
|
const node = cpNode[edge];
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
+
if (node === undefined) { continue; }
|
|
44
|
+
|
|
45
|
+
let node_ = nodeMap.get(node);
|
|
46
|
+
if (!node_) {
|
|
47
|
+
node_ = cloneWithoutEdges(node);
|
|
43
48
|
|
|
44
|
-
nodeMap.set(node,
|
|
45
|
-
cpStack.push({cpNode: node, newCpNode:
|
|
49
|
+
nodeMap.set(node, node_);
|
|
50
|
+
cpStack.push({ cpNode: node, newCpNode: node_ });
|
|
46
51
|
}
|
|
47
|
-
(newCpNode as CpNode)[edge] =
|
|
52
|
+
(newCpNode as CpNode)[edge] = node_ as CpNode;
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
|
|
@@ -52,14 +57,15 @@ function clone(cpNode: CpNode): CpNode {
|
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
|
|
55
|
-
function
|
|
60
|
+
function cloneWithoutEdges(cpNode: CpNode) {
|
|
56
61
|
const newNode = {
|
|
57
62
|
...cpNode,
|
|
58
63
|
...{
|
|
59
64
|
prev: undefined,
|
|
60
65
|
next: undefined,
|
|
61
66
|
prevOnCircle: undefined,
|
|
62
|
-
nextOnCircle: undefined
|
|
67
|
+
nextOnCircle: undefined,
|
|
68
|
+
holeCloserTwin: undefined
|
|
63
69
|
}
|
|
64
70
|
};
|
|
65
71
|
|