@adviser/cement 0.2.29 → 0.2.31
Sign up to get free protection for your applications and to get access to all the features.
- package/index.cjs +51 -13
- package/index.cjs.map +1 -1
- package/index.d.cts +19 -2
- package/index.d.ts +19 -2
- package/index.js +53 -16
- package/index.js.map +1 -1
- package/package.json +14 -14
- package/src/index.ts +1 -0
- package/src/jsr.json +4 -2
- package/src/refcounted.ts +23 -0
- package/src/uri.ts +43 -9
- package/src/utils/stripper.ts +59 -0
- package/ts/index.d.ts +1 -0
- package/ts/index.d.ts.map +1 -1
- package/ts/index.js +1 -0
- package/ts/index.js.map +1 -1
- package/ts/node/node-sys-abstraction.test.js +2 -6
- package/ts/node/node-sys-abstraction.test.js.map +1 -1
- package/ts/refcounted.d.ts +2 -0
- package/ts/refcounted.d.ts.map +1 -0
- package/ts/refcounted.js +19 -0
- package/ts/refcounted.js.map +1 -0
- package/ts/refcounted.test.d.ts +2 -0
- package/ts/refcounted.test.d.ts.map +1 -0
- package/ts/refcounted.test.js +39 -0
- package/ts/refcounted.test.js.map +1 -0
- package/ts/uri.d.ts +16 -1
- package/ts/uri.d.ts.map +1 -1
- package/ts/uri.js +21 -9
- package/ts/uri.js.map +1 -1
- package/ts/uri.test.js +28 -0
- package/ts/uri.test.js.map +1 -1
- package/ts/utils/stripper.d.ts +3 -0
- package/ts/utils/stripper.d.ts.map +1 -0
- package/ts/utils/stripper.js +56 -0
- package/ts/utils/stripper.js.map +1 -0
- package/ts/utils/stripper.test.d.ts +2 -0
- package/ts/utils/stripper.test.d.ts.map +1 -0
- package/ts/utils/stripper.test.js +97 -0
- package/ts/utils/stripper.test.js.map +1 -0
- package/src/base-sys-abstraction.test.ts +0 -95
- package/src/bin2text.test.ts +0 -59
- package/src/crypto.test.ts +0 -15
- package/src/future.test.ts +0 -32
- package/src/logger.test.ts +0 -1132
- package/src/resolve-once.test.ts +0 -321
- package/src/result.test.ts +0 -102
- package/src/sys-env.test.ts +0 -53
- package/src/tracer.test.ts +0 -314
- package/src/uri.test.ts +0 -155
@@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AAG,CAAC;AACb,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"stripper.test.d.ts","sourceRoot":"","sources":["../../../src/utils/stripper.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { stripper } from "./stripper.js";
|
2
|
+
const toStrip = {
|
3
|
+
main: "main",
|
4
|
+
Main: "main",
|
5
|
+
nested: {
|
6
|
+
main: "main",
|
7
|
+
Main: "main",
|
8
|
+
nested: {
|
9
|
+
main: "main",
|
10
|
+
Main: "main",
|
11
|
+
},
|
12
|
+
},
|
13
|
+
arrays: [
|
14
|
+
"main",
|
15
|
+
"Main",
|
16
|
+
{
|
17
|
+
main: "main",
|
18
|
+
Main: "main",
|
19
|
+
nested: {
|
20
|
+
main: "main",
|
21
|
+
Main: "main",
|
22
|
+
},
|
23
|
+
},
|
24
|
+
],
|
25
|
+
};
|
26
|
+
it("empty stripper", () => {
|
27
|
+
expect(stripper("", toStrip)).toEqual(toStrip);
|
28
|
+
});
|
29
|
+
it("array concrete stripper", () => {
|
30
|
+
expect(stripper(["main", "Main", "blub"], toStrip)).toEqual({
|
31
|
+
nested: {
|
32
|
+
nested: {},
|
33
|
+
},
|
34
|
+
arrays: [
|
35
|
+
"main",
|
36
|
+
"Main",
|
37
|
+
{
|
38
|
+
nested: {},
|
39
|
+
},
|
40
|
+
],
|
41
|
+
});
|
42
|
+
});
|
43
|
+
it("array simple regex concrete stripper", () => {
|
44
|
+
expect(stripper([/ain$/, "blub"], toStrip)).toEqual({
|
45
|
+
nested: {
|
46
|
+
nested: {},
|
47
|
+
},
|
48
|
+
arrays: [
|
49
|
+
"main",
|
50
|
+
"Main",
|
51
|
+
{
|
52
|
+
nested: {},
|
53
|
+
},
|
54
|
+
],
|
55
|
+
});
|
56
|
+
});
|
57
|
+
it("array regex concrete stripper", () => {
|
58
|
+
expect(stripper([/Main/, "blub"], toStrip)).toEqual({
|
59
|
+
main: "main",
|
60
|
+
nested: {
|
61
|
+
main: "main",
|
62
|
+
nested: {
|
63
|
+
main: "main",
|
64
|
+
},
|
65
|
+
},
|
66
|
+
arrays: [
|
67
|
+
"main",
|
68
|
+
"Main",
|
69
|
+
{
|
70
|
+
main: "main",
|
71
|
+
nested: {
|
72
|
+
main: "main",
|
73
|
+
},
|
74
|
+
},
|
75
|
+
],
|
76
|
+
});
|
77
|
+
});
|
78
|
+
it("array dotted concrete stripper", () => {
|
79
|
+
expect(stripper(["nested.main", "blub", "nested.nested.Main", "arrays[1]", "arrays[2].main", /arrays.2..nested..ain/], toStrip)).toEqual({
|
80
|
+
main: "main",
|
81
|
+
Main: "main",
|
82
|
+
nested: {
|
83
|
+
Main: "main",
|
84
|
+
nested: {
|
85
|
+
main: "main",
|
86
|
+
},
|
87
|
+
},
|
88
|
+
arrays: [
|
89
|
+
"main",
|
90
|
+
{
|
91
|
+
Main: "main",
|
92
|
+
nested: {},
|
93
|
+
},
|
94
|
+
],
|
95
|
+
});
|
96
|
+
});
|
97
|
+
//# sourceMappingURL=stripper.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"stripper.test.js","sourceRoot":"","sources":["../../../src/utils/stripper.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,OAAO,GAAG;IACd,IAAI,EAAE,MAAM;IACZ,IAAI,EAAE,MAAM;IACZ,MAAM,EAAE;QACN,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;SACb;KACF;IACD,MAAM,EAAE;QACN,MAAM;QACN,MAAM;QACN;YACE,IAAI,EAAE,MAAM;YACZ,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,IAAI,EAAE,MAAM;aACb;SACF;KACF;CACF,CAAC;AACF,EAAE,CAAC,gBAAgB,EAAE,GAAG,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EAAE;IACxC,MAAM,CACJ,QAAQ,CAAC,CAAC,aAAa,EAAE,MAAM,EAAE,oBAAoB,EAAE,WAAW,EAAE,gBAAgB,EAAE,uBAAuB,CAAC,EAAE,OAAO,CAAC,CACzH,CAAC,OAAO,CAAC;QACR,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE;YACN,IAAI,EAAE,MAAM;YACZ,MAAM,EAAE;gBACN,IAAI,EAAE,MAAM;aACb;SACF;QACD,MAAM,EAAE;YACN,MAAM;YACN;gBACE,IAAI,EAAE,MAAM;gBACZ,MAAM,EAAE,EAEP;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -1,95 +0,0 @@
|
|
1
|
-
import { runtimeFn, IDMode, TimeMode, RandomMode } from "@adviser/cement";
|
2
|
-
import { DenoSysAbstraction, NodeSysAbstraction } from "@adviser/cement/node";
|
3
|
-
import { WebSysAbstraction } from "@adviser/cement/web";
|
4
|
-
|
5
|
-
const abstractions = [];
|
6
|
-
|
7
|
-
if (runtimeFn().isNodeIsh) {
|
8
|
-
abstractions.push({ name: "NodeSysAbstraction", fn: NodeSysAbstraction });
|
9
|
-
}
|
10
|
-
|
11
|
-
if (runtimeFn().isDeno) {
|
12
|
-
abstractions.push({ name: "DenoSysAbstraction", fn: DenoSysAbstraction });
|
13
|
-
}
|
14
|
-
|
15
|
-
if (runtimeFn().isBrowser) {
|
16
|
-
abstractions.push({ name: "WebSysAbstraction", fn: WebSysAbstraction });
|
17
|
-
}
|
18
|
-
|
19
|
-
for (const abstraction of abstractions) {
|
20
|
-
describe(abstraction.name, () => {
|
21
|
-
it("IdService UUID", () => {
|
22
|
-
const sys = abstraction.fn();
|
23
|
-
const id1 = sys.NextId();
|
24
|
-
const id2 = sys.NextId();
|
25
|
-
expect(id1).not.toEqual(id2);
|
26
|
-
});
|
27
|
-
|
28
|
-
it("IdService explict UUID", () => {
|
29
|
-
const sys = abstraction.fn({ IdMode: IDMode.UUID });
|
30
|
-
const id1 = sys.NextId();
|
31
|
-
const id2 = sys.NextId();
|
32
|
-
expect(id1).not.toEqual(id2);
|
33
|
-
});
|
34
|
-
|
35
|
-
it("IdService const", () => {
|
36
|
-
const sys = abstraction.fn({ IdMode: IDMode.CONST });
|
37
|
-
const id1 = sys.NextId();
|
38
|
-
const id2 = sys.NextId();
|
39
|
-
expect(id1).toEqual(id2);
|
40
|
-
});
|
41
|
-
|
42
|
-
it("IdService set", () => {
|
43
|
-
for (let i = 0; i < 10; i++) {
|
44
|
-
const sys = abstraction.fn({ IdMode: IDMode.STEP });
|
45
|
-
const id1 = sys.NextId();
|
46
|
-
const id2 = sys.NextId();
|
47
|
-
expect(id1).toEqual("STEPId-0");
|
48
|
-
expect(id2).toEqual("STEPId-1");
|
49
|
-
}
|
50
|
-
});
|
51
|
-
|
52
|
-
it("time sleep", async () => {
|
53
|
-
const sys = abstraction.fn();
|
54
|
-
const start = sys.Time().Now();
|
55
|
-
await sys.Time().Sleep(100);
|
56
|
-
expect(sys.Time().TimeSince(start)).toBeGreaterThan(90);
|
57
|
-
});
|
58
|
-
|
59
|
-
it("time sleep const", async () => {
|
60
|
-
const sys = abstraction.fn({ TimeMode: TimeMode.REAL });
|
61
|
-
const start = new Date();
|
62
|
-
await sys.Time().Sleep(100);
|
63
|
-
const end = new Date();
|
64
|
-
expect(end.getTime() - start.getTime()).toBeGreaterThan(90);
|
65
|
-
});
|
66
|
-
|
67
|
-
it("time sleep step", async () => {
|
68
|
-
const sys = abstraction.fn({ TimeMode: TimeMode.STEP });
|
69
|
-
const start = sys.Time().Now();
|
70
|
-
await sys.Time().Sleep(86400500);
|
71
|
-
expect(sys.Time().Now().getTime() - start.getTime()).toEqual(86401500);
|
72
|
-
});
|
73
|
-
|
74
|
-
it("const random", () => {
|
75
|
-
const sys = abstraction.fn({ RandomMode: RandomMode.CONST });
|
76
|
-
expect(sys.Random0ToValue(10)).toEqual(5);
|
77
|
-
expect(sys.Random0ToValue(10)).toEqual(5);
|
78
|
-
});
|
79
|
-
|
80
|
-
it("step random", () => {
|
81
|
-
const sys = abstraction.fn({ RandomMode: RandomMode.STEP });
|
82
|
-
expect(sys.Random0ToValue(10000)).toEqual(1);
|
83
|
-
expect(sys.Random0ToValue(10000)).toEqual(2);
|
84
|
-
});
|
85
|
-
|
86
|
-
it("random", () => {
|
87
|
-
const sys = abstraction.fn({});
|
88
|
-
for (let i = 0; i < 100; i++) {
|
89
|
-
const val = sys.Random0ToValue(10);
|
90
|
-
expect(val).toBeGreaterThanOrEqual(0);
|
91
|
-
expect(val).toBeLessThanOrEqual(10);
|
92
|
-
}
|
93
|
-
});
|
94
|
-
});
|
95
|
-
}
|
package/src/bin2text.test.ts
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
import { bin2string, bin2text } from "./bin2text.js";
|
2
|
-
|
3
|
-
it("bin2hex empty", () => {
|
4
|
-
expect(bin2string(new Uint8Array())).toEqual("");
|
5
|
-
});
|
6
|
-
|
7
|
-
it("bin2hex one", () => {
|
8
|
-
expect(bin2string(new Uint8Array([64]))).toBe("0000 40 @");
|
9
|
-
});
|
10
|
-
|
11
|
-
it("bin2hex 12", () => {
|
12
|
-
const collector: string[] = [];
|
13
|
-
bin2text(new Uint8Array([1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc]), (line) => {
|
14
|
-
collector.push(line);
|
15
|
-
});
|
16
|
-
expect(collector).toEqual(["0000 01 02 03 04 04 05 06 07 08 09 0a 0b 0c ............."]);
|
17
|
-
});
|
18
|
-
|
19
|
-
it("bin2hex cut", () => {
|
20
|
-
const collector: string[] = [];
|
21
|
-
bin2text(
|
22
|
-
new Uint8Array(new Array(255).fill(1).map((_, i) => i)),
|
23
|
-
(line) => {
|
24
|
-
collector.push(line);
|
25
|
-
},
|
26
|
-
52,
|
27
|
-
);
|
28
|
-
expect(collector).toEqual([
|
29
|
-
"0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
|
30
|
-
"0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
|
31
|
-
"0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
|
32
|
-
"00f0>>f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ...............",
|
33
|
-
]);
|
34
|
-
});
|
35
|
-
|
36
|
-
it("bin2hex long", () => {
|
37
|
-
const collector: string[] = [];
|
38
|
-
bin2text(new Uint8Array(new Array(256).fill(1).map((_, i) => i % 0xff)), (line) => {
|
39
|
-
collector.push(line);
|
40
|
-
});
|
41
|
-
expect(collector).toEqual([
|
42
|
-
"0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
|
43
|
-
"0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
|
44
|
-
"0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
|
45
|
-
"0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>?",
|
46
|
-
"0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO",
|
47
|
-
"0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\\]^_",
|
48
|
-
"0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno",
|
49
|
-
"0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f pqrstuvwxyz{|}~.",
|
50
|
-
"0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................",
|
51
|
-
"0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................",
|
52
|
-
"00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af ................",
|
53
|
-
"00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf ................",
|
54
|
-
"00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf ................",
|
55
|
-
"00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df ................",
|
56
|
-
"00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef ................",
|
57
|
-
"00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe 00 ................",
|
58
|
-
]);
|
59
|
-
});
|
package/src/crypto.test.ts
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
import { toCryptoRuntime } from "./crypto.js";
|
2
|
-
|
3
|
-
it("not extractable import -> export", async () => {
|
4
|
-
const cp = toCryptoRuntime();
|
5
|
-
const key = cp.randomBytes(32);
|
6
|
-
const x = await cp.importKey("raw", key, "AES-CBC", false, ["encrypt"]);
|
7
|
-
expect(cp.exportKey("raw", x)).rejects.toThrowError(/key is not extractable/i);
|
8
|
-
});
|
9
|
-
|
10
|
-
it("extractable import -> export", async () => {
|
11
|
-
const cp = toCryptoRuntime();
|
12
|
-
const key = cp.randomBytes(32);
|
13
|
-
const x = await cp.importKey("raw", key, "AES-CBC", true, ["encrypt"]);
|
14
|
-
expect(new Uint8Array((await cp.exportKey("raw", x)) as ArrayBuffer)).toEqual(key);
|
15
|
-
});
|
package/src/future.test.ts
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
import { Future } from "@adviser/cement";
|
2
|
-
|
3
|
-
it("Create Future Happy", async () => {
|
4
|
-
const future = new Future();
|
5
|
-
const promise = future.asPromise();
|
6
|
-
expect(promise).toBeInstanceOf(Promise);
|
7
|
-
|
8
|
-
const asynced = new Promise((resolve, reject) => {
|
9
|
-
promise.then(resolve).catch(reject);
|
10
|
-
});
|
11
|
-
future.resolve("Hello World");
|
12
|
-
|
13
|
-
expect(await asynced).toBe("Hello World");
|
14
|
-
});
|
15
|
-
|
16
|
-
it("Create Future Sad", async () => {
|
17
|
-
const future = new Future();
|
18
|
-
const promise = future.asPromise();
|
19
|
-
expect(promise).toBeInstanceOf(Promise);
|
20
|
-
|
21
|
-
const asynced = new Promise((resolve, reject) => {
|
22
|
-
promise.then(resolve).catch(reject);
|
23
|
-
});
|
24
|
-
future.reject("Sad World");
|
25
|
-
|
26
|
-
try {
|
27
|
-
await asynced;
|
28
|
-
expect("Why").toBe("Sad World");
|
29
|
-
} catch (error) {
|
30
|
-
expect(error).toBe("Sad World");
|
31
|
-
}
|
32
|
-
});
|