@adviser/cement 0.2.29 → 0.2.30

Sign up to get free protection for your applications and to get access to all the features.
package/ts/index.d.ts CHANGED
@@ -19,5 +19,6 @@ export * from "./crypto.js";
19
19
  export * from "./base-sys-abstraction.js";
20
20
  export * from "./bin2text.js";
21
21
  export * from "./version.js";
22
+ export * from "./refcounted.js";
22
23
  export * as utils from "./utils/index.js";
23
24
  //# sourceMappingURL=index.d.ts.map
package/ts/index.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
package/ts/index.js CHANGED
@@ -19,5 +19,6 @@ export * from "./crypto.js";
19
19
  export * from "./base-sys-abstraction.js";
20
20
  export * from "./bin2text.js";
21
21
  export * from "./version.js";
22
+ export * from "./refcounted.js";
22
23
  export * as utils from "./utils/index.js";
23
24
  //# sourceMappingURL=index.js.map
package/ts/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,cAAc,sBAAsB,CAAC;AACrC,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC"}
@@ -42,15 +42,11 @@ describe("node_sys", () => {
42
42
  let fnExec;
43
43
  let execHandler = "tsx src/test/test-exit-handler.ts";
44
44
  beforeAll(async () => {
45
+ const { exec } = await import("node:child_process");
46
+ fnExec = exec;
45
47
  if (runtimeFn().isDeno) {
46
- const { exec } = await import("child_process");
47
- fnExec = exec;
48
48
  execHandler = "deno run --allow-net --allow-read --allow-run --unstable-sloppy-imports src/test/test-exit-handler.ts";
49
49
  }
50
- else {
51
- const { exec } = await import("child_process");
52
- fnExec = exec;
53
- }
54
50
  });
55
51
  it("just-exit", () => {
56
52
  return new Promise((done) => {
@@ -1 +1 @@
1
- {"version":3,"file":"node-sys-abstraction.test.js","sourceRoot":"","sources":["../../../src/node/node-sys-abstraction.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iB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C,IAAI,CAAC,IAAI,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function wrapRefcounted<T, M extends string>(t: T, method: M): T;
2
+ //# sourceMappingURL=refcounted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refcounted.d.ts","sourceRoot":"","sources":["../../src/refcounted.ts"],"names":[],"mappings":"AAKA,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,GAAG,CAAC,CAiBtE"}
@@ -0,0 +1,19 @@
1
+ export function wrapRefcounted(t, method) {
2
+ const my = t;
3
+ my.__refcounted = (my.__refcounted || 0) + 1;
4
+ if (my.__refcounted === 1) {
5
+ my.__unrefcounted = my[method];
6
+ const mRec = my;
7
+ mRec[method] = function () {
8
+ this.__refcounted--;
9
+ if (this.__refcounted === 0) {
10
+ this.__unrefcounted();
11
+ }
12
+ if (this.__refcounted < 0) {
13
+ throw new Error("already closed");
14
+ }
15
+ };
16
+ }
17
+ return t;
18
+ }
19
+ //# sourceMappingURL=refcounted.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refcounted.js","sourceRoot":"","sources":["../../src/refcounted.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,cAAc,CAAsB,CAAI,EAAE,MAAS;IACjE,MAAM,EAAE,GAAG,CAAqB,CAAC;IACjC,EAAE,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IAC7C,IAAI,EAAE,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;QAC1B,EAAE,CAAC,cAAc,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;QAC/B,MAAM,IAAI,GAAG,EAAgC,CAAC;QAC9C,IAAI,CAAC,MAAM,CAAC,GAAG;YACb,IAAI,CAAC,YAAY,EAAE,CAAC;YACpB,IAAI,IAAI,CAAC,YAAY,KAAK,CAAC,EAAE,CAAC;gBAC5B,IAAI,CAAC,cAAc,EAAE,CAAC;YACxB,CAAC;YACD,IAAI,IAAI,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACpC,CAAC;QACH,CAAC,CAAC;IACJ,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=refcounted.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"refcounted.test.d.ts","sourceRoot":"","sources":["../../src/refcounted.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
1
+ import { wrapRefcounted } from "./refcounted.js";
2
+ class RealInstance {
3
+ constructor(x) {
4
+ this.isOpen = true;
5
+ this.x = x;
6
+ }
7
+ wurst() {
8
+ return this.x++;
9
+ }
10
+ close() {
11
+ if (!this.isOpen) {
12
+ throw new Error("already closed");
13
+ }
14
+ this.isOpen = false;
15
+ }
16
+ }
17
+ it("simple", () => {
18
+ const obj = wrapRefcounted(new RealInstance(42), "close");
19
+ expect(obj.wurst()).toBe(42);
20
+ obj.close();
21
+ expect(() => obj.close()).toThrowError("already closed");
22
+ });
23
+ it("nested", () => {
24
+ const ri = new RealInstance(42);
25
+ const obj1 = wrapRefcounted(ri, "close");
26
+ const obj2 = wrapRefcounted(ri, "close");
27
+ expect(obj1).toBe(obj2);
28
+ expect(obj1.wurst()).toBe(42);
29
+ expect(obj2.wurst()).toBe(43);
30
+ obj2.close();
31
+ expect(obj2.isOpen).toBe(true);
32
+ expect(obj2.wurst()).toBe(44);
33
+ expect(obj1.wurst()).toBe(45);
34
+ obj1.close();
35
+ expect(obj1.wurst()).toBe(46);
36
+ expect(obj2.isOpen).toBe(false);
37
+ expect(() => obj2.close()).toThrowError("already closed");
38
+ });
39
+ //# sourceMappingURL=refcounted.test.js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,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC,gBAAgB,CAAC,CAAC;AAC5D,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
- }
@@ -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
- });
@@ -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
- });
@@ -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
- });