@vope/utils 1.4.18 → 1.4.20
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/cjs/index.js +181 -2
- package/lib/index.js +6 -2
- package/lib/neo4j.js +147 -0
- package/lib/parse/num.js +35 -0
- package/package.json +2 -1
- package/types/index.d.ts +2 -0
- package/types/neo4j.d.ts +62 -0
- package/types/parse/num.d.ts +8 -0
package/cjs/index.js
CHANGED
|
@@ -25,6 +25,7 @@ __export(src_exports, {
|
|
|
25
25
|
MemoryList: () => MemoryList,
|
|
26
26
|
MemoryPower: () => MemoryPower,
|
|
27
27
|
MemorySimple: () => MemorySimple,
|
|
28
|
+
Neo4j: () => Neo4j,
|
|
28
29
|
Subscriber: () => Subscriber,
|
|
29
30
|
Union: () => Union,
|
|
30
31
|
clamp: () => clamp,
|
|
@@ -49,6 +50,7 @@ __export(src_exports, {
|
|
|
49
50
|
joinPaths: () => joinPaths,
|
|
50
51
|
loadImage: () => loadImage,
|
|
51
52
|
once: () => once,
|
|
53
|
+
parseNum: () => parseNum,
|
|
52
54
|
rotateAngle: () => rotateAngle,
|
|
53
55
|
rotateRad: () => rotateRad,
|
|
54
56
|
wait: () => wait
|
|
@@ -589,6 +591,149 @@ var MemorySimple = class {
|
|
|
589
591
|
}
|
|
590
592
|
};
|
|
591
593
|
|
|
594
|
+
// src/neo4j.ts
|
|
595
|
+
var Neo4j = class {
|
|
596
|
+
#nid;
|
|
597
|
+
#sourceKey;
|
|
598
|
+
#targetKey;
|
|
599
|
+
#nodes;
|
|
600
|
+
#edges;
|
|
601
|
+
#sources;
|
|
602
|
+
#targets;
|
|
603
|
+
#dirs;
|
|
604
|
+
/**
|
|
605
|
+
* 点视图
|
|
606
|
+
*/
|
|
607
|
+
nodes;
|
|
608
|
+
/**
|
|
609
|
+
* 边视图
|
|
610
|
+
*/
|
|
611
|
+
edges;
|
|
612
|
+
/**
|
|
613
|
+
* (边)出点视图
|
|
614
|
+
*/
|
|
615
|
+
sources;
|
|
616
|
+
/**
|
|
617
|
+
* (边)入点视图
|
|
618
|
+
*/
|
|
619
|
+
targets;
|
|
620
|
+
/**
|
|
621
|
+
* (边)方向视图
|
|
622
|
+
*/
|
|
623
|
+
dirs;
|
|
624
|
+
constructor(nodeList, edgeList, {
|
|
625
|
+
nid,
|
|
626
|
+
eid,
|
|
627
|
+
sourceKey,
|
|
628
|
+
targetKey,
|
|
629
|
+
dir
|
|
630
|
+
}) {
|
|
631
|
+
shield(this, "nodes", this.#nodes = new MemorySimple(this.#nid = nid));
|
|
632
|
+
shield(this, "edges", this.#edges = new MemorySimple(eid));
|
|
633
|
+
shield(this, "sources", this.#sources = new MemoryList(this.#sourceKey = sourceKey));
|
|
634
|
+
shield(this, "targets", this.#targets = new MemoryList(this.#targetKey = targetKey));
|
|
635
|
+
shield(this, "dirs", this.#dirs = new MemoryList(dir));
|
|
636
|
+
nodeList.forEach((node) => this.node("add", node));
|
|
637
|
+
edgeList.forEach((edge) => this.edge("add", edge));
|
|
638
|
+
}
|
|
639
|
+
node(type, value) {
|
|
640
|
+
const nodes = this.#nodes;
|
|
641
|
+
if (type === "add") {
|
|
642
|
+
nodes.push(value);
|
|
643
|
+
} else if (type === "delete") {
|
|
644
|
+
const node = nodes.get(value);
|
|
645
|
+
if (!node)
|
|
646
|
+
return [];
|
|
647
|
+
nodes.delete(node);
|
|
648
|
+
const id = node[this.#nid];
|
|
649
|
+
const sourceKey = this.#sourceKey;
|
|
650
|
+
const targetKey = this.#targetKey;
|
|
651
|
+
const edges = this.#edges;
|
|
652
|
+
const sources = this.#sources;
|
|
653
|
+
const targets = this.#targets;
|
|
654
|
+
const dirs = this.#dirs;
|
|
655
|
+
const list = [];
|
|
656
|
+
sources.get(id)?.reduce((_, edge) => {
|
|
657
|
+
edges.delete(edge);
|
|
658
|
+
targets.delete(edge);
|
|
659
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
660
|
+
list.push(edge);
|
|
661
|
+
return true;
|
|
662
|
+
}, false) && sources.deleteType(id);
|
|
663
|
+
targets.get(id)?.reduce((_, edge) => {
|
|
664
|
+
edges.delete(edge);
|
|
665
|
+
sources.delete(edge);
|
|
666
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
667
|
+
list.push(edge);
|
|
668
|
+
return true;
|
|
669
|
+
}, false) && targets.deleteType(id);
|
|
670
|
+
return list;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
edge(type, value) {
|
|
674
|
+
const sourceKey = this.#sourceKey;
|
|
675
|
+
const targetKey = this.#targetKey;
|
|
676
|
+
const edges = this.#edges;
|
|
677
|
+
const sources = this.#sources;
|
|
678
|
+
const targets = this.#targets;
|
|
679
|
+
const dirs = this.#dirs;
|
|
680
|
+
if (type === "add") {
|
|
681
|
+
const edge = value;
|
|
682
|
+
edges.push(edge);
|
|
683
|
+
sources.push(edge);
|
|
684
|
+
targets.push(edge);
|
|
685
|
+
edge[sourceKey] === edge[targetKey] || dirs.push(edge);
|
|
686
|
+
} else if (type === "delete") {
|
|
687
|
+
const edge = edges.get(value);
|
|
688
|
+
if (!edge)
|
|
689
|
+
return false;
|
|
690
|
+
edges.delete(edge);
|
|
691
|
+
sources.delete(edge);
|
|
692
|
+
targets.delete(edge);
|
|
693
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
/**
|
|
698
|
+
* 清理图管理数据
|
|
699
|
+
*/
|
|
700
|
+
clear() {
|
|
701
|
+
this.#nodes.clear();
|
|
702
|
+
this.#edges.clear();
|
|
703
|
+
this.#sources.clear();
|
|
704
|
+
this.#targets.clear();
|
|
705
|
+
this.#dirs.clear();
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
var shield_keys = hash8strings([
|
|
709
|
+
"push",
|
|
710
|
+
"delete",
|
|
711
|
+
"deleteType",
|
|
712
|
+
"clear"
|
|
713
|
+
]);
|
|
714
|
+
var shield = (obj, key, origin) => {
|
|
715
|
+
const proxy = new Proxy({}, {
|
|
716
|
+
get(target, p) {
|
|
717
|
+
if (p in shield_keys)
|
|
718
|
+
return;
|
|
719
|
+
const value = origin[p];
|
|
720
|
+
if (typeof value === "function") {
|
|
721
|
+
return function(...args) {
|
|
722
|
+
const result = origin[p](...args);
|
|
723
|
+
return result === origin ? proxy : result;
|
|
724
|
+
};
|
|
725
|
+
} else {
|
|
726
|
+
return value;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
Object.defineProperty(obj, key, {
|
|
731
|
+
get() {
|
|
732
|
+
return proxy;
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
};
|
|
736
|
+
|
|
592
737
|
// src/once.ts
|
|
593
738
|
var once = (func, thisArg) => {
|
|
594
739
|
let local;
|
|
@@ -596,6 +741,40 @@ var once = (func, thisArg) => {
|
|
|
596
741
|
return (...list) => inited ? local : (inited = true, local = func.apply(thisArg, list));
|
|
597
742
|
};
|
|
598
743
|
|
|
744
|
+
// src/parse/num.ts
|
|
745
|
+
var import_lodash_es3 = require("lodash-es");
|
|
746
|
+
var pow = Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));
|
|
747
|
+
var re_num = /^([-+]?)0*(\d+)(?:(n)|(?:\.(\d+))?(?:[Ee]([-+]?)(\d+))?)$/;
|
|
748
|
+
var parseNum = (num) => {
|
|
749
|
+
if ((0, import_lodash_es3.isNumber)(num) || typeof num === "bigint")
|
|
750
|
+
return num;
|
|
751
|
+
const match = num.match(re_num);
|
|
752
|
+
if (!match)
|
|
753
|
+
return Number.NaN;
|
|
754
|
+
const [, valueSymbol, integer, bigint, decimal, powSymbol, powValue] = match;
|
|
755
|
+
if (bigint === "n")
|
|
756
|
+
return BigInt(valueSymbol + integer);
|
|
757
|
+
const powSize = integer.length - 1 + (powValue ? powSymbol === "-" ? -powValue : +powValue : 0);
|
|
758
|
+
if (powSize < pow || powSize === pow && +integer.slice(0, -1) < Number.MAX_SAFE_INTEGER / 10)
|
|
759
|
+
return +num;
|
|
760
|
+
try {
|
|
761
|
+
const bigValue = BigInt(integer.slice(0, powSize + 1).padEnd(powSize + 1, "0"));
|
|
762
|
+
let smallValue;
|
|
763
|
+
if (decimal && powValue && powSymbol !== "-") {
|
|
764
|
+
const powNum = +powValue;
|
|
765
|
+
const effectDecimal = decimal.slice(0, Math.min(pow, powNum));
|
|
766
|
+
const tinyValue = decimal.length > pow && powNum > pow ? BigInt(+decimal.slice(pow, powNum)) * BigInt(10 ** Math.max(powNum - decimal.length, 0)) : BigInt(0);
|
|
767
|
+
smallValue = BigInt(effectDecimal) * BigInt(10 ** (powNum - effectDecimal.length)) + tinyValue;
|
|
768
|
+
} else {
|
|
769
|
+
smallValue = BigInt(0);
|
|
770
|
+
}
|
|
771
|
+
const value = bigValue + smallValue;
|
|
772
|
+
return valueSymbol === "-" ? value * BigInt(-1) : value;
|
|
773
|
+
} catch {
|
|
774
|
+
return Number.NaN;
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
|
|
599
778
|
// src/rotate/rad.ts
|
|
600
779
|
var rotateRad = (from, rad, visit = [0, 0]) => {
|
|
601
780
|
const x = from[0] - visit[0];
|
|
@@ -610,7 +789,7 @@ var rotateRad = (from, rad, visit = [0, 0]) => {
|
|
|
610
789
|
var rotateAngle = (from, angle, visit) => rotateRad(from, angle / 180 * Math.PI, visit);
|
|
611
790
|
|
|
612
791
|
// src/style/css.ts
|
|
613
|
-
var
|
|
792
|
+
var import_lodash_es4 = require("lodash-es");
|
|
614
793
|
var hump = /[A-Z]/g;
|
|
615
794
|
var css = (...args) => {
|
|
616
795
|
const list = [];
|
|
@@ -618,7 +797,7 @@ var css = (...args) => {
|
|
|
618
797
|
const data = args[i];
|
|
619
798
|
if (!data)
|
|
620
799
|
continue;
|
|
621
|
-
if ((0,
|
|
800
|
+
if ((0, import_lodash_es4.isString)(data)) {
|
|
622
801
|
list.push(data);
|
|
623
802
|
} else if (Array.isArray(data)) {
|
|
624
803
|
const result = css(...data);
|
package/lib/index.js
CHANGED
|
@@ -17,12 +17,14 @@ import { MemoryBasic } from "./memory/basic";
|
|
|
17
17
|
import { MemoryList } from "./memory/list";
|
|
18
18
|
import { MemoryPower } from "./memory/power";
|
|
19
19
|
import { MemorySimple } from "./memory/simple";
|
|
20
|
+
import { default as default2 } from "./neo4j";
|
|
20
21
|
import { once } from "./once";
|
|
22
|
+
import { parseNum } from "./parse/num";
|
|
21
23
|
import { deconPowersSum } from "./power/decon";
|
|
22
24
|
import { rotateAngle } from "./rotate/angle";
|
|
23
25
|
import { rotateRad } from "./rotate/rad";
|
|
24
26
|
import { css } from "./style/css";
|
|
25
|
-
import { default as
|
|
27
|
+
import { default as default3 } from "./subscriber";
|
|
26
28
|
import { FlexTable } from "./table/flex";
|
|
27
29
|
import { Union } from "./union";
|
|
28
30
|
import { joinPaths } from "./url/join";
|
|
@@ -34,7 +36,8 @@ export {
|
|
|
34
36
|
MemoryList,
|
|
35
37
|
MemoryPower,
|
|
36
38
|
MemorySimple,
|
|
37
|
-
default2 as
|
|
39
|
+
default2 as Neo4j,
|
|
40
|
+
default3 as Subscriber,
|
|
38
41
|
Union,
|
|
39
42
|
clamp,
|
|
40
43
|
classnames,
|
|
@@ -58,6 +61,7 @@ export {
|
|
|
58
61
|
joinPaths,
|
|
59
62
|
loadImage,
|
|
60
63
|
once,
|
|
64
|
+
parseNum,
|
|
61
65
|
rotateAngle,
|
|
62
66
|
rotateRad,
|
|
63
67
|
wait
|
package/lib/neo4j.js
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { hash8strings } from "./convert/strings";
|
|
2
|
+
import { MemoryList } from "./memory/list";
|
|
3
|
+
import { MemorySimple } from "./memory/simple";
|
|
4
|
+
class Neo4j {
|
|
5
|
+
#nid;
|
|
6
|
+
#sourceKey;
|
|
7
|
+
#targetKey;
|
|
8
|
+
#nodes;
|
|
9
|
+
#edges;
|
|
10
|
+
#sources;
|
|
11
|
+
#targets;
|
|
12
|
+
#dirs;
|
|
13
|
+
/**
|
|
14
|
+
* 点视图
|
|
15
|
+
*/
|
|
16
|
+
nodes;
|
|
17
|
+
/**
|
|
18
|
+
* 边视图
|
|
19
|
+
*/
|
|
20
|
+
edges;
|
|
21
|
+
/**
|
|
22
|
+
* (边)出点视图
|
|
23
|
+
*/
|
|
24
|
+
sources;
|
|
25
|
+
/**
|
|
26
|
+
* (边)入点视图
|
|
27
|
+
*/
|
|
28
|
+
targets;
|
|
29
|
+
/**
|
|
30
|
+
* (边)方向视图
|
|
31
|
+
*/
|
|
32
|
+
dirs;
|
|
33
|
+
constructor(nodeList, edgeList, {
|
|
34
|
+
nid,
|
|
35
|
+
eid,
|
|
36
|
+
sourceKey,
|
|
37
|
+
targetKey,
|
|
38
|
+
dir
|
|
39
|
+
}) {
|
|
40
|
+
shield(this, "nodes", this.#nodes = new MemorySimple(this.#nid = nid));
|
|
41
|
+
shield(this, "edges", this.#edges = new MemorySimple(eid));
|
|
42
|
+
shield(this, "sources", this.#sources = new MemoryList(this.#sourceKey = sourceKey));
|
|
43
|
+
shield(this, "targets", this.#targets = new MemoryList(this.#targetKey = targetKey));
|
|
44
|
+
shield(this, "dirs", this.#dirs = new MemoryList(dir));
|
|
45
|
+
nodeList.forEach((node) => this.node("add", node));
|
|
46
|
+
edgeList.forEach((edge) => this.edge("add", edge));
|
|
47
|
+
}
|
|
48
|
+
node(type, value) {
|
|
49
|
+
const nodes = this.#nodes;
|
|
50
|
+
if (type === "add") {
|
|
51
|
+
nodes.push(value);
|
|
52
|
+
} else if (type === "delete") {
|
|
53
|
+
const node = nodes.get(value);
|
|
54
|
+
if (!node)
|
|
55
|
+
return [];
|
|
56
|
+
nodes.delete(node);
|
|
57
|
+
const id = node[this.#nid];
|
|
58
|
+
const sourceKey = this.#sourceKey;
|
|
59
|
+
const targetKey = this.#targetKey;
|
|
60
|
+
const edges = this.#edges;
|
|
61
|
+
const sources = this.#sources;
|
|
62
|
+
const targets = this.#targets;
|
|
63
|
+
const dirs = this.#dirs;
|
|
64
|
+
const list = [];
|
|
65
|
+
sources.get(id)?.reduce((_, edge) => {
|
|
66
|
+
edges.delete(edge);
|
|
67
|
+
targets.delete(edge);
|
|
68
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
69
|
+
list.push(edge);
|
|
70
|
+
return true;
|
|
71
|
+
}, false) && sources.deleteType(id);
|
|
72
|
+
targets.get(id)?.reduce((_, edge) => {
|
|
73
|
+
edges.delete(edge);
|
|
74
|
+
sources.delete(edge);
|
|
75
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
76
|
+
list.push(edge);
|
|
77
|
+
return true;
|
|
78
|
+
}, false) && targets.deleteType(id);
|
|
79
|
+
return list;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
edge(type, value) {
|
|
83
|
+
const sourceKey = this.#sourceKey;
|
|
84
|
+
const targetKey = this.#targetKey;
|
|
85
|
+
const edges = this.#edges;
|
|
86
|
+
const sources = this.#sources;
|
|
87
|
+
const targets = this.#targets;
|
|
88
|
+
const dirs = this.#dirs;
|
|
89
|
+
if (type === "add") {
|
|
90
|
+
const edge = value;
|
|
91
|
+
edges.push(edge);
|
|
92
|
+
sources.push(edge);
|
|
93
|
+
targets.push(edge);
|
|
94
|
+
edge[sourceKey] === edge[targetKey] || dirs.push(edge);
|
|
95
|
+
} else if (type === "delete") {
|
|
96
|
+
const edge = edges.get(value);
|
|
97
|
+
if (!edge)
|
|
98
|
+
return false;
|
|
99
|
+
edges.delete(edge);
|
|
100
|
+
sources.delete(edge);
|
|
101
|
+
targets.delete(edge);
|
|
102
|
+
edge[sourceKey] === edge[targetKey] || dirs.delete(edge);
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* 清理图管理数据
|
|
108
|
+
*/
|
|
109
|
+
clear() {
|
|
110
|
+
this.#nodes.clear();
|
|
111
|
+
this.#edges.clear();
|
|
112
|
+
this.#sources.clear();
|
|
113
|
+
this.#targets.clear();
|
|
114
|
+
this.#dirs.clear();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const shield_keys = hash8strings([
|
|
118
|
+
"push",
|
|
119
|
+
"delete",
|
|
120
|
+
"deleteType",
|
|
121
|
+
"clear"
|
|
122
|
+
]);
|
|
123
|
+
const shield = (obj, key, origin) => {
|
|
124
|
+
const proxy = new Proxy({}, {
|
|
125
|
+
get(target, p) {
|
|
126
|
+
if (p in shield_keys)
|
|
127
|
+
return;
|
|
128
|
+
const value = origin[p];
|
|
129
|
+
if (typeof value === "function") {
|
|
130
|
+
return function(...args) {
|
|
131
|
+
const result = origin[p](...args);
|
|
132
|
+
return result === origin ? proxy : result;
|
|
133
|
+
};
|
|
134
|
+
} else {
|
|
135
|
+
return value;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
Object.defineProperty(obj, key, {
|
|
140
|
+
get() {
|
|
141
|
+
return proxy;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
export {
|
|
146
|
+
Neo4j as default
|
|
147
|
+
};
|
package/lib/parse/num.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isNumber } from "lodash-es";
|
|
2
|
+
const pow = Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));
|
|
3
|
+
const re_num = /^([-+]?)0*(\d+)(?:(n)|(?:\.(\d+))?(?:[Ee]([-+]?)(\d+))?)$/;
|
|
4
|
+
const parseNum = (num) => {
|
|
5
|
+
if (isNumber(num) || typeof num === "bigint")
|
|
6
|
+
return num;
|
|
7
|
+
const match = num.match(re_num);
|
|
8
|
+
if (!match)
|
|
9
|
+
return Number.NaN;
|
|
10
|
+
const [, valueSymbol, integer, bigint, decimal, powSymbol, powValue] = match;
|
|
11
|
+
if (bigint === "n")
|
|
12
|
+
return BigInt(valueSymbol + integer);
|
|
13
|
+
const powSize = integer.length - 1 + (powValue ? powSymbol === "-" ? -powValue : +powValue : 0);
|
|
14
|
+
if (powSize < pow || powSize === pow && +integer.slice(0, -1) < Number.MAX_SAFE_INTEGER / 10)
|
|
15
|
+
return +num;
|
|
16
|
+
try {
|
|
17
|
+
const bigValue = BigInt(integer.slice(0, powSize + 1).padEnd(powSize + 1, "0"));
|
|
18
|
+
let smallValue;
|
|
19
|
+
if (decimal && powValue && powSymbol !== "-") {
|
|
20
|
+
const powNum = +powValue;
|
|
21
|
+
const effectDecimal = decimal.slice(0, Math.min(pow, powNum));
|
|
22
|
+
const tinyValue = decimal.length > pow && powNum > pow ? BigInt(+decimal.slice(pow, powNum)) * BigInt(10 ** Math.max(powNum - decimal.length, 0)) : BigInt(0);
|
|
23
|
+
smallValue = BigInt(effectDecimal) * BigInt(10 ** (powNum - effectDecimal.length)) + tinyValue;
|
|
24
|
+
} else {
|
|
25
|
+
smallValue = BigInt(0);
|
|
26
|
+
}
|
|
27
|
+
const value = bigValue + smallValue;
|
|
28
|
+
return valueSymbol === "-" ? value * BigInt(-1) : value;
|
|
29
|
+
} catch {
|
|
30
|
+
return Number.NaN;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
export {
|
|
34
|
+
parseNum
|
|
35
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vope/utils",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.20",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"typescript": "^5.3.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
+
"@type-challenges/utils": "^0.1.1",
|
|
52
53
|
"@types/lodash-es": "^4.17.9",
|
|
53
54
|
"@vope/types": "^1.0.12",
|
|
54
55
|
"csstype": "^3.1.3",
|
package/types/index.d.ts
CHANGED
|
@@ -17,7 +17,9 @@ export { MemoryBasic } from './memory/basic';
|
|
|
17
17
|
export { MemoryList } from './memory/list';
|
|
18
18
|
export { MemoryPower } from './memory/power';
|
|
19
19
|
export { MemorySimple } from './memory/simple';
|
|
20
|
+
export { default as Neo4j } from './neo4j';
|
|
20
21
|
export { once } from './once';
|
|
22
|
+
export { parseNum } from './parse/num';
|
|
21
23
|
export { deconPowersSum } from './power/decon';
|
|
22
24
|
export { rotateAngle } from './rotate/angle';
|
|
23
25
|
export { rotateRad } from './rotate/rad';
|
package/types/neo4j.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Equal } from '@type-challenges/utils';
|
|
2
|
+
import { GetGivenProps } from '@vope/types';
|
|
3
|
+
import { MemoryList } from './memory/list';
|
|
4
|
+
import { MemorySimple } from './memory/simple';
|
|
5
|
+
interface Config<INode extends object, IEdge extends object> {
|
|
6
|
+
nid: GetGivenProps<INode, string> & string;
|
|
7
|
+
eid: GetGivenProps<IEdge, string> & string;
|
|
8
|
+
sourceKey: GetGivenProps<IEdge, string> & string;
|
|
9
|
+
targetKey: GetGivenProps<IEdge, string> & string;
|
|
10
|
+
dir(edge: IEdge): string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 图管理
|
|
14
|
+
*/
|
|
15
|
+
export default class Neo4j<INode extends object, IEdge extends object> {
|
|
16
|
+
#private;
|
|
17
|
+
/**
|
|
18
|
+
* 点视图
|
|
19
|
+
*/
|
|
20
|
+
nodes: Shield<MemorySimple<INode, string>>;
|
|
21
|
+
/**
|
|
22
|
+
* 边视图
|
|
23
|
+
*/
|
|
24
|
+
edges: Shield<MemorySimple<IEdge, string>>;
|
|
25
|
+
/**
|
|
26
|
+
* (边)出点视图
|
|
27
|
+
*/
|
|
28
|
+
sources: Shield<MemoryList<IEdge, string>>;
|
|
29
|
+
/**
|
|
30
|
+
* (边)入点视图
|
|
31
|
+
*/
|
|
32
|
+
targets: Shield<MemoryList<IEdge, string>>;
|
|
33
|
+
/**
|
|
34
|
+
* (边)方向视图
|
|
35
|
+
*/
|
|
36
|
+
dirs: Shield<MemoryList<IEdge, string>>;
|
|
37
|
+
constructor(nodeList: INode[], edgeList: IEdge[], { nid, eid, sourceKey, targetKey, dir, }: Config<INode, IEdge>);
|
|
38
|
+
/**
|
|
39
|
+
* 点操作
|
|
40
|
+
*/
|
|
41
|
+
node(type: 'add', value: INode): void;
|
|
42
|
+
node(type: 'delete', value: string): IEdge[];
|
|
43
|
+
/**
|
|
44
|
+
* 边操作
|
|
45
|
+
*/
|
|
46
|
+
edge(type: 'add', value: IEdge): void;
|
|
47
|
+
edge(type: 'delete', value: string): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* 清理图管理数据
|
|
50
|
+
*/
|
|
51
|
+
clear(): void;
|
|
52
|
+
}
|
|
53
|
+
declare const shield_keys: {
|
|
54
|
+
push: number;
|
|
55
|
+
clear: number;
|
|
56
|
+
delete: number;
|
|
57
|
+
deleteType: number;
|
|
58
|
+
};
|
|
59
|
+
type Shield<T> = {
|
|
60
|
+
[P in Exclude<keyof T, keyof typeof shield_keys>]: T[P] extends (...args: infer A) => infer B ? Equal<B, T> extends true ? (...args: A) => Shield<T> : T[P] : T[P];
|
|
61
|
+
};
|
|
62
|
+
export {};
|