@adviser/cement 0.0.0-jsr-t1
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +201 -0
- package/README.md +39 -0
- package/base-sys-abstraction-BkEiLHl0.d.ts +193 -0
- package/base-sys-abstraction-Qj7pkY1N.d.cts +193 -0
- package/chunk-7KFVMTOS.js +311 -0
- package/chunk-7KFVMTOS.js.map +1 -0
- package/chunk-GES3MUGV.js +92 -0
- package/chunk-GES3MUGV.js.map +1 -0
- package/chunk-Q65HLCNL.js +601 -0
- package/chunk-Q65HLCNL.js.map +1 -0
- package/chunk-WMMUXBDX.js +87 -0
- package/chunk-WMMUXBDX.js.map +1 -0
- package/index-Q3phXzYr.d.cts +75 -0
- package/index-tIGZMHTc.d.ts +75 -0
- package/index.cjs +2593 -0
- package/index.cjs.map +1 -0
- package/index.d.cts +532 -0
- package/index.d.ts +532 -0
- package/index.js +1533 -0
- package/index.js.map +1 -0
- package/node/index.cjs +924 -0
- package/node/index.cjs.map +1 -0
- package/node/index.d.cts +65 -0
- package/node/index.d.ts +65 -0
- package/node/index.js +398 -0
- package/node/index.js.map +1 -0
- package/package.json +81 -0
- package/src/base-sys-abstraction.test.ts +95 -0
- package/src/base-sys-abstraction.ts +242 -0
- package/src/bin2text.test.ts +59 -0
- package/src/bin2text.ts +47 -0
- package/src/crypto.test.ts +15 -0
- package/src/crypto.ts +125 -0
- package/src/file-service.ts +24 -0
- package/src/future.test.ts +32 -0
- package/src/future.ts +27 -0
- package/src/index.ts +22 -0
- package/src/jsr.json +20 -0
- package/src/log-level-impl.ts +87 -0
- package/src/log-writer-impl.ts +58 -0
- package/src/logger-impl.ts +498 -0
- package/src/logger.test.ts +1132 -0
- package/src/logger.ts +208 -0
- package/src/node/deno-file-service.ts +92 -0
- package/src/node/deno-sys-abstraction.ts +133 -0
- package/src/node/index.ts +4 -0
- package/src/node/mock-file-service.ts +45 -0
- package/src/node/node-file-service.ts +91 -0
- package/src/node/node-sys-abstraction.ts +121 -0
- package/src/option.ts +60 -0
- package/src/resolve-once.test.ts +321 -0
- package/src/resolve-once.ts +179 -0
- package/src/result.test.ts +102 -0
- package/src/result.ts +165 -0
- package/src/runtime.ts +36 -0
- package/src/sys-abstraction.ts +53 -0
- package/src/sys-env.test.ts +53 -0
- package/src/sys-env.ts +216 -0
- package/src/test/log-write-stream.ts +95 -0
- package/src/test/mock-logger.ts +40 -0
- package/src/time.ts +20 -0
- package/src/tracer.test.ts +314 -0
- package/src/tracer.ts +222 -0
- package/src/txt-en-decoder.ts +21 -0
- package/src/uri.test.ts +155 -0
- package/src/uri.ts +421 -0
- package/src/utils/console-write-stream.ts +72 -0
- package/src/utils/fanout-write-stream.ts +32 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/rebuffer.ts +75 -0
- package/src/utils/stream-map.ts +67 -0
- package/src/utils/stream2string.ts +47 -0
- package/src/utils/string2stream.ts +14 -0
- package/src/version.ts +3 -0
- package/src/web/index.ts +1 -0
- package/src/web/web-sys-abstraction.ts +80 -0
- package/ts/LICENSE +201 -0
- package/ts/README.md +39 -0
- package/ts/base-sys-abstraction.d.ts +84 -0
- package/ts/base-sys-abstraction.d.ts.map +1 -0
- package/ts/base-sys-abstraction.js +178 -0
- package/ts/base-sys-abstraction.js.map +1 -0
- package/ts/base-sys-abstraction.test.d.ts +2 -0
- package/ts/base-sys-abstraction.test.d.ts.map +1 -0
- package/ts/base-sys-abstraction.test.js +82 -0
- package/ts/base-sys-abstraction.test.js.map +1 -0
- package/ts/bin2text.d.ts +3 -0
- package/ts/bin2text.d.ts.map +1 -0
- package/ts/bin2text.js +43 -0
- package/ts/bin2text.js.map +1 -0
- package/ts/bin2text.test.d.ts +2 -0
- package/ts/bin2text.test.d.ts.map +1 -0
- package/ts/bin2text.test.js +51 -0
- package/ts/bin2text.test.js.map +1 -0
- package/ts/crypto.d.ts +76 -0
- package/ts/crypto.d.ts.map +1 -0
- package/ts/crypto.js +22 -0
- package/ts/crypto.js.map +1 -0
- package/ts/crypto.test.d.ts +2 -0
- package/ts/crypto.test.d.ts.map +1 -0
- package/ts/crypto.test.js +14 -0
- package/ts/crypto.test.js.map +1 -0
- package/ts/file-service.d.ts +17 -0
- package/ts/file-service.d.ts.map +1 -0
- package/ts/file-service.js +2 -0
- package/ts/file-service.js.map +1 -0
- package/ts/future.d.ts +8 -0
- package/ts/future.d.ts.map +1 -0
- package/ts/future.js +38 -0
- package/ts/future.js.map +1 -0
- package/ts/future.test.d.ts +2 -0
- package/ts/future.test.d.ts.map +1 -0
- package/ts/future.test.js +28 -0
- package/ts/future.test.js.map +1 -0
- package/ts/index.d.ts +23 -0
- package/ts/index.d.ts.map +1 -0
- package/ts/index.js +23 -0
- package/ts/index.js.map +1 -0
- package/ts/log-level-impl.d.ts +14 -0
- package/ts/log-level-impl.d.ts.map +1 -0
- package/ts/log-level-impl.js +72 -0
- package/ts/log-level-impl.js.map +1 -0
- package/ts/log-writer-impl.d.ts +10 -0
- package/ts/log-writer-impl.d.ts.map +1 -0
- package/ts/log-writer-impl.js +45 -0
- package/ts/log-writer-impl.js.map +1 -0
- package/ts/logger-impl.d.ts +71 -0
- package/ts/logger-impl.d.ts.map +1 -0
- package/ts/logger-impl.js +412 -0
- package/ts/logger-impl.js.map +1 -0
- package/ts/logger.d.ts +84 -0
- package/ts/logger.d.ts.map +1 -0
- package/ts/logger.js +114 -0
- package/ts/logger.js.map +1 -0
- package/ts/logger.test.d.ts +2 -0
- package/ts/logger.test.d.ts.map +1 -0
- package/ts/logger.test.js +1023 -0
- package/ts/logger.test.js.map +1 -0
- package/ts/node/deno-file-service.d.ts +17 -0
- package/ts/node/deno-file-service.d.ts.map +1 -0
- package/ts/node/deno-file-service.js +65 -0
- package/ts/node/deno-file-service.js.map +1 -0
- package/ts/node/deno-sys-abstraction.d.ts +22 -0
- package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
- package/ts/node/deno-sys-abstraction.js +101 -0
- package/ts/node/deno-sys-abstraction.js.map +1 -0
- package/ts/node/index.d.ts +5 -0
- package/ts/node/index.d.ts.map +1 -0
- package/ts/node/index.js +5 -0
- package/ts/node/index.js.map +1 -0
- package/ts/node/mock-file-service.d.ts +11 -0
- package/ts/node/mock-file-service.d.ts.map +1 -0
- package/ts/node/mock-file-service.js +34 -0
- package/ts/node/mock-file-service.js.map +1 -0
- package/ts/node/mock-file-service.test.d.ts +2 -0
- package/ts/node/mock-file-service.test.d.ts.map +1 -0
- package/ts/node/mock-file-service.test.js +31 -0
- package/ts/node/mock-file-service.test.js.map +1 -0
- package/ts/node/node-file-service.d.ts +16 -0
- package/ts/node/node-file-service.d.ts.map +1 -0
- package/ts/node/node-file-service.js +71 -0
- package/ts/node/node-file-service.js.map +1 -0
- package/ts/node/node-sys-abstraction.d.ts +22 -0
- package/ts/node/node-sys-abstraction.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.js +99 -0
- package/ts/node/node-sys-abstraction.js.map +1 -0
- package/ts/node/node-sys-abstraction.test.d.ts +2 -0
- package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
- package/ts/node/node-sys-abstraction.test.js +87 -0
- package/ts/node/node-sys-abstraction.test.js.map +1 -0
- package/ts/option.d.ts +25 -0
- package/ts/option.d.ts.map +1 -0
- package/ts/option.js +47 -0
- package/ts/option.js.map +1 -0
- package/ts/resolve-once.d.ts +46 -0
- package/ts/resolve-once.d.ts.map +1 -0
- package/ts/resolve-once.js +152 -0
- package/ts/resolve-once.js.map +1 -0
- package/ts/resolve-once.test.d.ts +2 -0
- package/ts/resolve-once.test.d.ts.map +1 -0
- package/ts/resolve-once.test.js +283 -0
- package/ts/resolve-once.test.js.map +1 -0
- package/ts/result.d.ts +34 -0
- package/ts/result.d.ts.map +1 -0
- package/ts/result.js +85 -0
- package/ts/result.js.map +1 -0
- package/ts/result.test.d.ts +2 -0
- package/ts/result.test.d.ts.map +1 -0
- package/ts/result.test.js +79 -0
- package/ts/result.test.js.map +1 -0
- package/ts/runtime.d.ts +8 -0
- package/ts/runtime.d.ts.map +1 -0
- package/ts/runtime.js +26 -0
- package/ts/runtime.js.map +1 -0
- package/ts/sys-abstraction.d.ts +36 -0
- package/ts/sys-abstraction.d.ts.map +1 -0
- package/ts/sys-abstraction.js +31 -0
- package/ts/sys-abstraction.js.map +1 -0
- package/ts/sys-env.d.ts +48 -0
- package/ts/sys-env.d.ts.map +1 -0
- package/ts/sys-env.js +176 -0
- package/ts/sys-env.js.map +1 -0
- package/ts/sys-env.test.d.ts +2 -0
- package/ts/sys-env.test.d.ts.map +1 -0
- package/ts/sys-env.test.js +51 -0
- package/ts/sys-env.test.js.map +1 -0
- package/ts/test/log-write-stream.d.ts +27 -0
- package/ts/test/log-write-stream.d.ts.map +1 -0
- package/ts/test/log-write-stream.js +74 -0
- package/ts/test/log-write-stream.js.map +1 -0
- package/ts/test/mock-logger.d.ts +14 -0
- package/ts/test/mock-logger.d.ts.map +1 -0
- package/ts/test/mock-logger.js +29 -0
- package/ts/test/mock-logger.js.map +1 -0
- package/ts/test/mock-logger.test.d.ts +2 -0
- package/ts/test/mock-logger.test.d.ts.map +1 -0
- package/ts/test/mock-logger.test.js +63 -0
- package/ts/test/mock-logger.test.js.map +1 -0
- package/ts/test/test-exit-handler.d.ts +2 -0
- package/ts/test/test-exit-handler.d.ts.map +1 -0
- package/ts/test/test-exit-handler.js +57 -0
- package/ts/test/test-exit-handler.js.map +1 -0
- package/ts/time.d.ts +13 -0
- package/ts/time.d.ts.map +1 -0
- package/ts/time.js +14 -0
- package/ts/time.js.map +1 -0
- package/ts/tracer.d.ts +59 -0
- package/ts/tracer.d.ts.map +1 -0
- package/ts/tracer.js +148 -0
- package/ts/tracer.js.map +1 -0
- package/ts/tracer.test.d.ts +2 -0
- package/ts/tracer.test.d.ts.map +1 -0
- package/ts/tracer.test.js +311 -0
- package/ts/tracer.test.js.map +1 -0
- package/ts/txt-en-decoder.d.ts +10 -0
- package/ts/txt-en-decoder.d.ts.map +1 -0
- package/ts/txt-en-decoder.js +15 -0
- package/ts/txt-en-decoder.js.map +1 -0
- package/ts/uri.d.ts +67 -0
- package/ts/uri.d.ts.map +1 -0
- package/ts/uri.js +283 -0
- package/ts/uri.js.map +1 -0
- package/ts/uri.test.d.ts +2 -0
- package/ts/uri.test.d.ts.map +1 -0
- package/ts/uri.test.js +119 -0
- package/ts/uri.test.js.map +1 -0
- package/ts/utils/console-write-stream.d.ts +21 -0
- package/ts/utils/console-write-stream.d.ts.map +1 -0
- package/ts/utils/console-write-stream.js +62 -0
- package/ts/utils/console-write-stream.js.map +1 -0
- package/ts/utils/fanout-write-stream.d.ts +12 -0
- package/ts/utils/fanout-write-stream.d.ts.map +1 -0
- package/ts/utils/fanout-write-stream.js +24 -0
- package/ts/utils/fanout-write-stream.js.map +1 -0
- package/ts/utils/index.d.ts +7 -0
- package/ts/utils/index.d.ts.map +1 -0
- package/ts/utils/index.js +7 -0
- package/ts/utils/index.js.map +1 -0
- package/ts/utils/rebuffer.d.ts +3 -0
- package/ts/utils/rebuffer.d.ts.map +1 -0
- package/ts/utils/rebuffer.js +60 -0
- package/ts/utils/rebuffer.js.map +1 -0
- package/ts/utils/rebuffer.test.d.ts +2 -0
- package/ts/utils/rebuffer.test.d.ts.map +1 -0
- package/ts/utils/rebuffer.test.js +77 -0
- package/ts/utils/rebuffer.test.js.map +1 -0
- package/ts/utils/stream-map.d.ts +9 -0
- package/ts/utils/stream-map.d.ts.map +1 -0
- package/ts/utils/stream-map.js +62 -0
- package/ts/utils/stream-map.js.map +1 -0
- package/ts/utils/stream-map.test.d.ts +2 -0
- package/ts/utils/stream-map.test.d.ts.map +1 -0
- package/ts/utils/stream-map.test.js +87 -0
- package/ts/utils/stream-map.test.js.map +1 -0
- package/ts/utils/stream-test-helper.d.ts +17 -0
- package/ts/utils/stream-test-helper.d.ts.map +1 -0
- package/ts/utils/stream-test-helper.js +37 -0
- package/ts/utils/stream-test-helper.js.map +1 -0
- package/ts/utils/stream2string.d.ts +3 -0
- package/ts/utils/stream2string.d.ts.map +1 -0
- package/ts/utils/stream2string.js +48 -0
- package/ts/utils/stream2string.js.map +1 -0
- package/ts/utils/stream2string.test.d.ts +2 -0
- package/ts/utils/stream2string.test.d.ts.map +1 -0
- package/ts/utils/stream2string.test.js +29 -0
- package/ts/utils/stream2string.test.js.map +1 -0
- package/ts/utils/string2stream.d.ts +4 -0
- package/ts/utils/string2stream.d.ts.map +1 -0
- package/ts/utils/string2stream.js +13 -0
- package/ts/utils/string2stream.js.map +1 -0
- package/ts/utils/string2stream.test.d.ts +2 -0
- package/ts/utils/string2stream.test.d.ts.map +1 -0
- package/ts/utils/string2stream.test.js +6 -0
- package/ts/utils/string2stream.test.js.map +1 -0
- package/ts/version.d.ts +2 -0
- package/ts/version.d.ts.map +1 -0
- package/ts/version.js +4 -0
- package/ts/version.js.map +1 -0
- package/ts/web/index.d.ts +2 -0
- package/ts/web/index.d.ts.map +1 -0
- package/ts/web/index.js +2 -0
- package/ts/web/index.js.map +1 -0
- package/ts/web/web-sys-abstraction.d.ts +4 -0
- package/ts/web/web-sys-abstraction.d.ts.map +1 -0
- package/ts/web/web-sys-abstraction.js +64 -0
- package/ts/web/web-sys-abstraction.js.map +1 -0
- package/txt-en-decoder-CZYJUju2.d.cts +11 -0
- package/txt-en-decoder-CZYJUju2.d.ts +11 -0
- package/utils/index.cjs +341 -0
- package/utils/index.cjs.map +1 -0
- package/utils/index.d.cts +2 -0
- package/utils/index.d.ts +2 -0
- package/utils/index.js +32 -0
- package/utils/index.js.map +1 -0
- package/web/index.cjs +593 -0
- package/web/index.cjs.map +1 -0
- package/web/index.d.cts +6 -0
- package/web/index.d.ts +6 -0
- package/web/index.js +9 -0
- package/web/index.js.map +1 -0
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base-sys-abstraction.test.d.ts","sourceRoot":"","sources":["../../src/base-sys-abstraction.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,82 @@
|
|
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
|
+
const abstractions = [];
|
5
|
+
if (runtimeFn().isNodeIsh) {
|
6
|
+
abstractions.push({ name: "NodeSysAbstraction", fn: NodeSysAbstraction });
|
7
|
+
}
|
8
|
+
if (runtimeFn().isDeno) {
|
9
|
+
abstractions.push({ name: "DenoSysAbstraction", fn: DenoSysAbstraction });
|
10
|
+
}
|
11
|
+
if (runtimeFn().isBrowser) {
|
12
|
+
abstractions.push({ name: "WebSysAbstraction", fn: WebSysAbstraction });
|
13
|
+
}
|
14
|
+
for (const abstraction of abstractions) {
|
15
|
+
describe(abstraction.name, () => {
|
16
|
+
it("IdService UUID", () => {
|
17
|
+
const sys = abstraction.fn();
|
18
|
+
const id1 = sys.NextId();
|
19
|
+
const id2 = sys.NextId();
|
20
|
+
expect(id1).not.toEqual(id2);
|
21
|
+
});
|
22
|
+
it("IdService explict UUID", () => {
|
23
|
+
const sys = abstraction.fn({ IdMode: IDMode.UUID });
|
24
|
+
const id1 = sys.NextId();
|
25
|
+
const id2 = sys.NextId();
|
26
|
+
expect(id1).not.toEqual(id2);
|
27
|
+
});
|
28
|
+
it("IdService const", () => {
|
29
|
+
const sys = abstraction.fn({ IdMode: IDMode.CONST });
|
30
|
+
const id1 = sys.NextId();
|
31
|
+
const id2 = sys.NextId();
|
32
|
+
expect(id1).toEqual(id2);
|
33
|
+
});
|
34
|
+
it("IdService set", () => {
|
35
|
+
for (let i = 0; i < 10; i++) {
|
36
|
+
const sys = abstraction.fn({ IdMode: IDMode.STEP });
|
37
|
+
const id1 = sys.NextId();
|
38
|
+
const id2 = sys.NextId();
|
39
|
+
expect(id1).toEqual("STEPId-0");
|
40
|
+
expect(id2).toEqual("STEPId-1");
|
41
|
+
}
|
42
|
+
});
|
43
|
+
it("time sleep", async () => {
|
44
|
+
const sys = abstraction.fn();
|
45
|
+
const start = sys.Time().Now();
|
46
|
+
await sys.Time().Sleep(100);
|
47
|
+
expect(sys.Time().TimeSince(start)).toBeGreaterThan(90);
|
48
|
+
});
|
49
|
+
it("time sleep const", async () => {
|
50
|
+
const sys = abstraction.fn({ TimeMode: TimeMode.REAL });
|
51
|
+
const start = new Date();
|
52
|
+
await sys.Time().Sleep(100);
|
53
|
+
const end = new Date();
|
54
|
+
expect(end.getTime() - start.getTime()).toBeGreaterThan(90);
|
55
|
+
});
|
56
|
+
it("time sleep step", async () => {
|
57
|
+
const sys = abstraction.fn({ TimeMode: TimeMode.STEP });
|
58
|
+
const start = sys.Time().Now();
|
59
|
+
await sys.Time().Sleep(86400500);
|
60
|
+
expect(sys.Time().Now().getTime() - start.getTime()).toEqual(86401500);
|
61
|
+
});
|
62
|
+
it("const random", () => {
|
63
|
+
const sys = abstraction.fn({ RandomMode: RandomMode.CONST });
|
64
|
+
expect(sys.Random0ToValue(10)).toEqual(5);
|
65
|
+
expect(sys.Random0ToValue(10)).toEqual(5);
|
66
|
+
});
|
67
|
+
it("step random", () => {
|
68
|
+
const sys = abstraction.fn({ RandomMode: RandomMode.STEP });
|
69
|
+
expect(sys.Random0ToValue(10000)).toEqual(1);
|
70
|
+
expect(sys.Random0ToValue(10000)).toEqual(2);
|
71
|
+
});
|
72
|
+
it("random", () => {
|
73
|
+
const sys = abstraction.fn({});
|
74
|
+
for (let i = 0; i < 100; i++) {
|
75
|
+
const val = sys.Random0ToValue(10);
|
76
|
+
expect(val).toBeGreaterThanOrEqual(0);
|
77
|
+
expect(val).toBeLessThanOrEqual(10);
|
78
|
+
}
|
79
|
+
});
|
80
|
+
});
|
81
|
+
}
|
82
|
+
//# sourceMappingURL=base-sys-abstraction.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"base-sys-abstraction.test.js","sourceRoot":"","sources":["../../src/base-sys-abstraction.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC1E,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"],"names":[],"mappings":"AAAA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EAAE,IAAI,SAAI,GAAG,IAAI,CAkC7F;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,eAAe,EAAE,IAAI,SAAI,GAAG,MAAM,CAUjE"}
|
package/ts/bin2text.js
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
export function bin2text(hex, lineFn, size = 0) {
|
2
|
+
const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
|
3
|
+
let cutted = " ";
|
4
|
+
if (size == 0) {
|
5
|
+
size = arr.length;
|
6
|
+
}
|
7
|
+
size = Math.min(size, arr.length);
|
8
|
+
const cols = 16;
|
9
|
+
for (let line = 0; line < size; line += cols) {
|
10
|
+
if (line + cols <= size || arr.length == size) {
|
11
|
+
}
|
12
|
+
else {
|
13
|
+
line = arr.length - (arr.length % cols);
|
14
|
+
size = arr.length;
|
15
|
+
cutted = ">>";
|
16
|
+
}
|
17
|
+
const l = [line.toString(16).padStart(4, "0"), cutted];
|
18
|
+
for (let col = 0; col < cols; col++) {
|
19
|
+
if (line + col < size) {
|
20
|
+
l.push(arr[line + col].toString(16).padStart(2, "0"));
|
21
|
+
}
|
22
|
+
else {
|
23
|
+
l.push(" ");
|
24
|
+
}
|
25
|
+
l.push(" ");
|
26
|
+
}
|
27
|
+
for (let col = 0; col < cols; col++) {
|
28
|
+
if (line + col < size) {
|
29
|
+
const ch = arr[line + col];
|
30
|
+
l.push(ch >= 32 && ch < 127 ? String.fromCharCode(ch) : ".");
|
31
|
+
}
|
32
|
+
}
|
33
|
+
lineFn(l.join(""));
|
34
|
+
}
|
35
|
+
}
|
36
|
+
export function bin2string(hex, size = 0) {
|
37
|
+
const collector = [];
|
38
|
+
bin2text(hex, (line) => {
|
39
|
+
collector.push(line);
|
40
|
+
}, size);
|
41
|
+
return collector.join("\n");
|
42
|
+
}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
import { bin2string, bin2text } from "./bin2text.js";
|
2
|
+
it("bin2hex empty", () => {
|
3
|
+
expect(bin2string(new Uint8Array())).toEqual("");
|
4
|
+
});
|
5
|
+
it("bin2hex one", () => {
|
6
|
+
expect(bin2string(new Uint8Array([64]))).toBe("0000 40 @");
|
7
|
+
});
|
8
|
+
it("bin2hex 12", () => {
|
9
|
+
const collector = [];
|
10
|
+
bin2text(new Uint8Array([1, 2, 3, 4, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc]), (line) => {
|
11
|
+
collector.push(line);
|
12
|
+
});
|
13
|
+
expect(collector).toEqual(["0000 01 02 03 04 04 05 06 07 08 09 0a 0b 0c ............."]);
|
14
|
+
});
|
15
|
+
it("bin2hex cut", () => {
|
16
|
+
const collector = [];
|
17
|
+
bin2text(new Uint8Array(new Array(255).fill(1).map((_, i) => i)), (line) => {
|
18
|
+
collector.push(line);
|
19
|
+
}, 52);
|
20
|
+
expect(collector).toEqual([
|
21
|
+
"0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
|
22
|
+
"0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
|
23
|
+
"0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
|
24
|
+
"00f0>>f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe ...............",
|
25
|
+
]);
|
26
|
+
});
|
27
|
+
it("bin2hex long", () => {
|
28
|
+
const collector = [];
|
29
|
+
bin2text(new Uint8Array(new Array(256).fill(1).map((_, i) => i % 0xff)), (line) => {
|
30
|
+
collector.push(line);
|
31
|
+
});
|
32
|
+
expect(collector).toEqual([
|
33
|
+
"0000 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f ................",
|
34
|
+
"0010 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f ................",
|
35
|
+
"0020 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f !\"#$%&'()*+,-./",
|
36
|
+
"0030 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 0123456789:;<=>?",
|
37
|
+
"0040 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f @ABCDEFGHIJKLMNO",
|
38
|
+
"0050 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f PQRSTUVWXYZ[\\]^_",
|
39
|
+
"0060 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f `abcdefghijklmno",
|
40
|
+
"0070 70 71 72 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f pqrstuvwxyz{|}~.",
|
41
|
+
"0080 80 81 82 83 84 85 86 87 88 89 8a 8b 8c 8d 8e 8f ................",
|
42
|
+
"0090 90 91 92 93 94 95 96 97 98 99 9a 9b 9c 9d 9e 9f ................",
|
43
|
+
"00a0 a0 a1 a2 a3 a4 a5 a6 a7 a8 a9 aa ab ac ad ae af ................",
|
44
|
+
"00b0 b0 b1 b2 b3 b4 b5 b6 b7 b8 b9 ba bb bc bd be bf ................",
|
45
|
+
"00c0 c0 c1 c2 c3 c4 c5 c6 c7 c8 c9 ca cb cc cd ce cf ................",
|
46
|
+
"00d0 d0 d1 d2 d3 d4 d5 d6 d7 d8 d9 da db dc dd de df ................",
|
47
|
+
"00e0 e0 e1 e2 e3 e4 e5 e6 e7 e8 e9 ea eb ec ed ee ef ................",
|
48
|
+
"00f0 f0 f1 f2 f3 f4 f5 f6 f7 f8 f9 fa fb fc fd fe 00 ................",
|
49
|
+
]);
|
50
|
+
});
|
51
|
+
//# sourceMappingURL=bin2text.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"bin2text.test.js","sourceRoot":"","sources":["../../src/bin2text.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAErD,EAAE,CAAC,eAAe,EAAE,GAAG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wE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,uEAAuE;KACxE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,cAAc,EAAE,GAAG,EAAE;IACtB,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,QAAQ,CAAC,IAAI,UAAU,CAAC,IAAI,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE;QAChF,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC;QACxB,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;QACxE,wEAAwE;KACzE,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/ts/crypto.d.ts
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
export interface CTJsonWebKey {
|
2
|
+
alg?: string;
|
3
|
+
crv?: string;
|
4
|
+
d?: string;
|
5
|
+
dp?: string;
|
6
|
+
dq?: string;
|
7
|
+
e?: string;
|
8
|
+
ext?: boolean;
|
9
|
+
k?: string;
|
10
|
+
key_ops?: string[];
|
11
|
+
kty?: string;
|
12
|
+
n?: string;
|
13
|
+
oth?: RsaOtherPrimesInfo[];
|
14
|
+
p?: string;
|
15
|
+
q?: string;
|
16
|
+
qi?: string;
|
17
|
+
use?: string;
|
18
|
+
x?: string;
|
19
|
+
y?: string;
|
20
|
+
}
|
21
|
+
export type CTKeyFormat = "jwk" | "pkcs8" | "raw" | "spki";
|
22
|
+
export type CTKeyUsage = "decrypt" | "deriveBits" | "deriveKey" | "encrypt" | "sign" | "unwrapKey" | "verify" | "wrapKey";
|
23
|
+
export interface CTAlgorithm {
|
24
|
+
name: string;
|
25
|
+
}
|
26
|
+
export type CTAlgorithmIdentifier = CTAlgorithm | string;
|
27
|
+
export interface CTRsaHashedImportParams extends CTAlgorithm {
|
28
|
+
hash: CTAlgorithmIdentifier;
|
29
|
+
}
|
30
|
+
export type CTNamedCurve = string;
|
31
|
+
export interface CTEcKeyImportParams extends CTAlgorithm {
|
32
|
+
namedCurve: CTNamedCurve;
|
33
|
+
}
|
34
|
+
export interface CTHmacImportParams extends CTAlgorithm {
|
35
|
+
hash: CTAlgorithmIdentifier;
|
36
|
+
length?: number;
|
37
|
+
}
|
38
|
+
export interface CTAesKeyAlgorithm extends CTAlgorithm {
|
39
|
+
length: number;
|
40
|
+
}
|
41
|
+
export type CTKeyType = "private" | "public" | "secret";
|
42
|
+
export interface CTCryptoKey {
|
43
|
+
readonly algorithm: CTAlgorithm;
|
44
|
+
readonly extractable: boolean;
|
45
|
+
readonly type: CTKeyType;
|
46
|
+
readonly usages: CTKeyUsage[];
|
47
|
+
}
|
48
|
+
interface CTArrayBufferTypes {
|
49
|
+
ArrayBuffer: ArrayBuffer;
|
50
|
+
}
|
51
|
+
type CTArrayBufferLike = CTArrayBufferTypes[keyof CTArrayBufferTypes];
|
52
|
+
export interface CTArrayBufferView {
|
53
|
+
buffer: CTArrayBufferLike;
|
54
|
+
byteLength: number;
|
55
|
+
byteOffset: number;
|
56
|
+
}
|
57
|
+
export type CTBufferSource = CTArrayBufferView | ArrayBuffer;
|
58
|
+
export interface CryptoRuntime {
|
59
|
+
importKey(format: CTKeyFormat, keyData: CTJsonWebKey | CTBufferSource, algorithm: CTAlgorithmIdentifier | CTRsaHashedImportParams | CTEcKeyImportParams | CTHmacImportParams | CTAesKeyAlgorithm, extractable: boolean, keyUsages: CTKeyUsage[]): Promise<CTCryptoKey>;
|
60
|
+
exportKey(format: CTKeyFormat, key: CTCryptoKey): Promise<CTJsonWebKey | ArrayBuffer>;
|
61
|
+
decrypt(algo: {
|
62
|
+
name: string;
|
63
|
+
iv: Uint8Array;
|
64
|
+
tagLength: number;
|
65
|
+
}, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;
|
66
|
+
encrypt(algo: {
|
67
|
+
name: string;
|
68
|
+
iv: Uint8Array;
|
69
|
+
tagLength: number;
|
70
|
+
}, key: CTCryptoKey, data: Uint8Array): Promise<ArrayBuffer>;
|
71
|
+
digestSHA256(data: Uint8Array): Promise<ArrayBuffer>;
|
72
|
+
randomBytes(size: number): Uint8Array;
|
73
|
+
}
|
74
|
+
export declare function toCryptoRuntime(cryptoOpts?: Partial<CryptoRuntime>): CryptoRuntime;
|
75
|
+
export {};
|
76
|
+
//# sourceMappingURL=crypto.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"crypto.d.ts","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,kBAAkB,EAAE,CAAC;IAC3B,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,CAAC,CAAC,EAAE,MAAM,CAAC;IACX,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ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+1,22 @@
|
|
1
|
+
function randomBytes(size) {
|
2
|
+
const bytes = new Uint8Array(size);
|
3
|
+
if (size > 0) {
|
4
|
+
crypto.getRandomValues(bytes);
|
5
|
+
}
|
6
|
+
return bytes;
|
7
|
+
}
|
8
|
+
function digestSHA256(data) {
|
9
|
+
return Promise.resolve(crypto.subtle.digest("SHA-256", data));
|
10
|
+
}
|
11
|
+
export function toCryptoRuntime(cryptoOpts = {}) {
|
12
|
+
const runtime = {
|
13
|
+
importKey: cryptoOpts.importKey || crypto.subtle.importKey.bind(crypto.subtle),
|
14
|
+
exportKey: cryptoOpts.exportKey || crypto.subtle.exportKey.bind(crypto.subtle),
|
15
|
+
encrypt: cryptoOpts.encrypt || crypto.subtle.encrypt.bind(crypto.subtle),
|
16
|
+
decrypt: cryptoOpts.decrypt || crypto.subtle.decrypt.bind(crypto.subtle),
|
17
|
+
randomBytes: cryptoOpts.randomBytes || randomBytes,
|
18
|
+
digestSHA256: cryptoOpts.digestSHA256 || digestSHA256,
|
19
|
+
};
|
20
|
+
return runtime;
|
21
|
+
}
|
22
|
+
//# sourceMappingURL=crypto.js.map
|
package/ts/crypto.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../src/crypto.ts"],"names":[],"mappings":"AAqGA,SAAS,WAAW,CAAC,IAAY;IAC/B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,IAAI,GAAG,CAAC,EAAE,CAAC;QACb,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,YAAY,CAAC,IAAgB;IACpC,OAAO,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;AAChE,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,aAAqC,EAAE;IACrE,MAAM,OAAO,GAAG;QACd,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9E,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QAC9E,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACxE,OAAO,EAAE,UAAU,CAAC,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC;QACxE,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,WAAW;QAClD,YAAY,EAAE,UAAU,CAAC,YAAY,IAAI,YAAY;KACtD,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"crypto.test.d.ts","sourceRoot":"","sources":["../../src/crypto.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { toCryptoRuntime } from "./crypto.js";
|
2
|
+
it("not extractable import -> export", async () => {
|
3
|
+
const cp = toCryptoRuntime();
|
4
|
+
const key = cp.randomBytes(32);
|
5
|
+
const x = await cp.importKey("raw", key, "AES-CBC", false, ["encrypt"]);
|
6
|
+
expect(cp.exportKey("raw", x)).rejects.toThrowError(/key is not extractable/i);
|
7
|
+
});
|
8
|
+
it("extractable import -> export", async () => {
|
9
|
+
const cp = toCryptoRuntime();
|
10
|
+
const key = cp.randomBytes(32);
|
11
|
+
const x = await cp.importKey("raw", key, "AES-CBC", true, ["encrypt"]);
|
12
|
+
expect(new Uint8Array((await cp.exportKey("raw", x)))).toEqual(key);
|
13
|
+
});
|
14
|
+
//# sourceMappingURL=crypto.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"crypto.test.js","sourceRoot":"","sources":["../../src/crypto.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,EAAE,CAAC,kCAAkC,EAAE,KAAK,IAAI,EAAE;IAChD,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACxE,MAAM,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,yBAAyB,CAAC,CAAC;AACjF,CAAC,CAAC,CAAC;AAEH,EAAE,CAAC,8BAA8B,EAAE,KAAK,IAAI,EAAE;IAC5C,MAAM,EAAE,GAAG,eAAe,EAAE,CAAC;IAC7B,MAAM,GAAG,GAAG,EAAE,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IAC/B,MAAM,CAAC,GAAG,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC;IACvE,MAAM,CAAC,IAAI,UAAU,CAAC,CAAC,MAAM,EAAE,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAgB,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AACrF,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
export interface NamedWritableStream {
|
2
|
+
readonly name: string;
|
3
|
+
readonly stream: WritableStream<Uint8Array>;
|
4
|
+
}
|
5
|
+
export interface FileService {
|
6
|
+
readonly baseDir: string;
|
7
|
+
create(fname: string): Promise<NamedWritableStream>;
|
8
|
+
readFileString(fname: string): Promise<string>;
|
9
|
+
writeFileString(fname: string, content: string): Promise<void>;
|
10
|
+
abs(fname: string): string;
|
11
|
+
join(...paths: string[]): string;
|
12
|
+
relative(from: string, to?: string): string;
|
13
|
+
dirname(fname: string): string;
|
14
|
+
basename(fname: string): string;
|
15
|
+
isAbsolute(fname: string): boolean;
|
16
|
+
}
|
17
|
+
//# sourceMappingURL=file-service.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-service.d.ts","sourceRoot":"","sources":["../../src/file-service.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,UAAU,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IACpD,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE/D,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAE3B,IAAI,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;IAEjC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE5C,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC;IAIhC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CACpC"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"file-service.js","sourceRoot":"","sources":["../../src/file-service.ts"],"names":[],"mappings":""}
|
package/ts/future.d.ts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"future.d.ts","sourceRoot":"","sources":["../../src/future.ts"],"names":[],"mappings":"AAAA,qBAAa,MAAM,CAAC,CAAC;;;IAgBb,SAAS,IAAI,OAAO,CAAC,CAAC,CAAC;IAI7B,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI;IAGvB,MAAM,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;CAG9B"}
|
package/ts/future.js
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
6
|
+
};
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
11
|
+
};
|
12
|
+
var _Future_promise, _Future_resolveFn, _Future_rejectFn;
|
13
|
+
export class Future {
|
14
|
+
constructor() {
|
15
|
+
_Future_promise.set(this, void 0);
|
16
|
+
_Future_resolveFn.set(this, () => {
|
17
|
+
throw new Error("This Promise is not working as expected.");
|
18
|
+
});
|
19
|
+
_Future_rejectFn.set(this, () => {
|
20
|
+
throw new Error("This Promise is not working as expected.");
|
21
|
+
});
|
22
|
+
__classPrivateFieldSet(this, _Future_promise, new Promise((resolve, reject) => {
|
23
|
+
__classPrivateFieldSet(this, _Future_resolveFn, resolve, "f");
|
24
|
+
__classPrivateFieldSet(this, _Future_rejectFn, reject, "f");
|
25
|
+
}), "f");
|
26
|
+
}
|
27
|
+
async asPromise() {
|
28
|
+
return __classPrivateFieldGet(this, _Future_promise, "f");
|
29
|
+
}
|
30
|
+
resolve(value) {
|
31
|
+
__classPrivateFieldGet(this, _Future_resolveFn, "f").call(this, value);
|
32
|
+
}
|
33
|
+
reject(reason) {
|
34
|
+
__classPrivateFieldGet(this, _Future_rejectFn, "f").call(this, reason);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
_Future_promise = new WeakMap(), _Future_resolveFn = new WeakMap(), _Future_rejectFn = new WeakMap();
|
38
|
+
//# sourceMappingURL=future.js.map
|
package/ts/future.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"future.js","sourceRoot":"","sources":["../../src/future.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAM,OAAO,MAAM;IASjB;QARS,kCAAqB;QAC9B,4BAAiC,GAAG,EAAE;YACpC,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC,EAAC;QACF,2BAAuC,GAAG,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC,EAAC;QAGA,uBAAA,IAAI,mBAAY,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,uBAAA,IAAI,qBAAc,OAAO,MAAA,CAAC;YAC1B,uBAAA,IAAI,oBAAa,MAAM,MAAA,CAAC;QAC1B,CAAC,CAAC,MAAA,CAAC;IACL,CAAC;IAED,KAAK,CAAC,SAAS;QACb,OAAO,uBAAA,IAAI,uBAAS,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,KAAQ;QACd,uBAAA,IAAI,yBAAW,MAAf,IAAI,EAAY,KAAK,CAAC,CAAC;IACzB,CAAC;IACD,MAAM,CAAC,MAAe;QACpB,uBAAA,IAAI,wBAAU,MAAd,IAAI,EAAW,MAAM,CAAC,CAAC;IACzB,CAAC;CACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"future.test.d.ts","sourceRoot":"","sources":["../../src/future.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
import { Future } from "@adviser/cement";
|
2
|
+
it("Create Future Happy", async () => {
|
3
|
+
const future = new Future();
|
4
|
+
const promise = future.asPromise();
|
5
|
+
expect(promise).toBeInstanceOf(Promise);
|
6
|
+
const asynced = new Promise((resolve, reject) => {
|
7
|
+
promise.then(resolve).catch(reject);
|
8
|
+
});
|
9
|
+
future.resolve("Hello World");
|
10
|
+
expect(await asynced).toBe("Hello World");
|
11
|
+
});
|
12
|
+
it("Create Future Sad", async () => {
|
13
|
+
const future = new Future();
|
14
|
+
const promise = future.asPromise();
|
15
|
+
expect(promise).toBeInstanceOf(Promise);
|
16
|
+
const asynced = new Promise((resolve, reject) => {
|
17
|
+
promise.then(resolve).catch(reject);
|
18
|
+
});
|
19
|
+
future.reject("Sad World");
|
20
|
+
try {
|
21
|
+
await asynced;
|
22
|
+
expect("Why").toBe("Sad World");
|
23
|
+
}
|
24
|
+
catch (error) {
|
25
|
+
expect(error).toBe("Sad World");
|
26
|
+
}
|
27
|
+
});
|
28
|
+
//# sourceMappingURL=future.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"future.test.js","sourceRoot":"","sources":["../../src/future.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,EAAE,CAAC,qBAAqB,EAAE,KAAK,IAAI,EAAE;IACnC,MAAM,MAAM,GAAG,IAAI,MAAM,EAAE,CAAC;IAC5B,MAAM,OAAO,GAAG,MA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logger.js";
|
4
|
+
export * from "./sys-abstraction.js";
|
5
|
+
export * from "./sys-env.js";
|
6
|
+
export * from "./time.js";
|
7
|
+
export * from "./test/log-write-stream.js";
|
8
|
+
export * from "./test/mock-logger.js";
|
9
|
+
export * from "./txt-en-decoder.js";
|
10
|
+
export * from "./log-level-impl.js";
|
11
|
+
export * from "./result.js";
|
12
|
+
export * from "./option.js";
|
13
|
+
export * from "./future.js";
|
14
|
+
export * from "./tracer.js";
|
15
|
+
export * from "./resolve-once.js";
|
16
|
+
export * from "./runtime.js";
|
17
|
+
export * from "./uri.js";
|
18
|
+
export * from "./crypto.js";
|
19
|
+
export * from "./base-sys-abstraction.js";
|
20
|
+
export * from "./bin2text.js";
|
21
|
+
export * from "./version.js";
|
22
|
+
export * as utils from "./utils/index.js";
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +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"}
|
package/ts/index.js
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
export * from "./file-service.js";
|
2
|
+
export * from "./logger-impl.js";
|
3
|
+
export * from "./logger.js";
|
4
|
+
export * from "./sys-abstraction.js";
|
5
|
+
export * from "./sys-env.js";
|
6
|
+
export * from "./time.js";
|
7
|
+
export * from "./test/log-write-stream.js";
|
8
|
+
export * from "./test/mock-logger.js";
|
9
|
+
export * from "./txt-en-decoder.js";
|
10
|
+
export * from "./log-level-impl.js";
|
11
|
+
export * from "./result.js";
|
12
|
+
export * from "./option.js";
|
13
|
+
export * from "./future.js";
|
14
|
+
export * from "./tracer.js";
|
15
|
+
export * from "./resolve-once.js";
|
16
|
+
export * from "./runtime.js";
|
17
|
+
export * from "./uri.js";
|
18
|
+
export * from "./crypto.js";
|
19
|
+
export * from "./base-sys-abstraction.js";
|
20
|
+
export * from "./bin2text.js";
|
21
|
+
export * from "./version.js";
|
22
|
+
export * as utils from "./utils/index.js";
|
23
|
+
//# sourceMappingURL=index.js.map
|
package/ts/index.js.map
ADDED
@@ -0,0 +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"}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { LevelHandler, Level } from "./logger.js";
|
2
|
+
export declare class LevelHandlerImpl implements LevelHandler {
|
3
|
+
readonly _globalLevels: Set<Level>;
|
4
|
+
readonly _modules: Map<string, Set<Level>>;
|
5
|
+
isStackExposed: boolean;
|
6
|
+
enableLevel(level: Level, ...modules: string[]): void;
|
7
|
+
disableLevel(level: Level, ...modules: string[]): void;
|
8
|
+
setExposeStack(enable?: boolean): void;
|
9
|
+
forModules(level: Level, fnAction: (p: string) => void, ...modules: (string | string[])[]): void;
|
10
|
+
setDebug(...modules: (string | string[])[]): void;
|
11
|
+
isEnabled(ilevel: unknown, module: unknown): boolean;
|
12
|
+
}
|
13
|
+
export declare function LevelHandlerSingleton(): LevelHandler;
|
14
|
+
//# sourceMappingURL=log-level-impl.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"log-level-impl.d.ts","sourceRoot":"","sources":["../../src/log-level-impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAElD,qBAAa,gBAAiB,YAAW,YAAY;IACnD,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAC,KAAK,CAAC,CAAyD;IAC3F,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC,CAAC,CAAiC;IAC3E,cAAc,UAAS;IACvB,WAAW,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IAarD,YAAY,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI;IActD,cAAc,CAAC,MAAM,CAAC,EAAE,OAAO,GAAG,IAAI;IAItC,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI;IAchG,QAAQ,CAAC,GAAG,OAAO,EAAE,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI;IASjD,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO;CAoBrD;AAID,wBAAgB,qBAAqB,IAAI,YAAY,CAEpD"}
|