@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
package/ts/time.js
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
export class Time {
|
2
|
+
TimeSince(start) {
|
3
|
+
const now = this.Now();
|
4
|
+
return now.getTime() - start.getTime();
|
5
|
+
}
|
6
|
+
}
|
7
|
+
export var TimeUnits;
|
8
|
+
(function (TimeUnits) {
|
9
|
+
TimeUnits[TimeUnits["Microsecond"] = 1] = "Microsecond";
|
10
|
+
TimeUnits[TimeUnits["Second"] = 1000] = "Second";
|
11
|
+
TimeUnits[TimeUnits["Minute"] = 60000] = "Minute";
|
12
|
+
TimeUnits[TimeUnits["Hour"] = 3600000] = "Hour";
|
13
|
+
})(TimeUnits || (TimeUnits = {}));
|
14
|
+
//# sourceMappingURL=time.js.map
|
package/ts/time.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"time.js","sourceRoot":"","sources":["../../src/time.ts"],"names":[],"mappings":"AAAA,MAAM,OAAgB,IAAI;IAGxB,SAAS,CAAC,KAAW;QACnB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC;IACzC,CAAC;CACF;AAID,MAAM,CAAN,IAAY,SAQX;AARD,WAAY,SAAS;IACnB,uDAAe,CAAA;IAEf,gDAA2B,CAAA;IAE3B,iDAAoB,CAAA;IAEpB,+CAAkB,CAAA;AACpB,CAAC,EARW,SAAS,KAAT,SAAS,QAQpB"}
|
package/ts/tracer.d.ts
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
import { Time } from "./time.js";
|
2
|
+
import { Logger } from "./logger.js";
|
3
|
+
export type TraceCtx = {
|
4
|
+
readonly spanId: string;
|
5
|
+
readonly time: Time;
|
6
|
+
readonly parent: TraceNode;
|
7
|
+
readonly metrics: Map<string, Metric<unknown>>;
|
8
|
+
readonly logger?: Logger;
|
9
|
+
} & Record<string, unknown>;
|
10
|
+
export type CleanCtx = {
|
11
|
+
readonly spanId: string;
|
12
|
+
} & Record<string, unknown>;
|
13
|
+
export type TraceCtxParam = {
|
14
|
+
readonly spanId: string;
|
15
|
+
} & Partial<{
|
16
|
+
readonly time: Time;
|
17
|
+
readonly parent: TraceNode;
|
18
|
+
readonly logger: Logger;
|
19
|
+
}> & Record<string, unknown>;
|
20
|
+
export declare class Metric<T> {
|
21
|
+
value?: T;
|
22
|
+
readonly path: string;
|
23
|
+
constructor(path: string);
|
24
|
+
set(value: T): void;
|
25
|
+
add<R extends number | ArrayLike<T>>(value: R): void;
|
26
|
+
}
|
27
|
+
export type MetricMap = Map<string, Metric<unknown>>;
|
28
|
+
export declare class Metrics {
|
29
|
+
readonly tracenode: TraceNode;
|
30
|
+
private readonly map;
|
31
|
+
readonly spanRefs: MetricMap;
|
32
|
+
constructor(tracenode: TraceNode);
|
33
|
+
toJSON(): Record<string, unknown>;
|
34
|
+
get<T>(ipath: string): Metric<T>;
|
35
|
+
}
|
36
|
+
export interface Invokaction {
|
37
|
+
readonly result: "success" | "error";
|
38
|
+
readonly start: number;
|
39
|
+
readonly end: number;
|
40
|
+
readonly metrics?: Metrics;
|
41
|
+
}
|
42
|
+
export type TraceNodeMap = Map<string, TraceNode>;
|
43
|
+
export declare class TraceNode {
|
44
|
+
readonly childs: TraceNodeMap;
|
45
|
+
readonly invokations: Invokaction[];
|
46
|
+
readonly spanId: string;
|
47
|
+
readonly ctx: TraceCtx;
|
48
|
+
readonly metrics: Metrics;
|
49
|
+
static root(time: Time, logger?: Logger): TraceNode;
|
50
|
+
constructor(ctx: TraceCtx);
|
51
|
+
getRootPath(rpath?: string[]): string;
|
52
|
+
invokes(): {
|
53
|
+
ctx: CleanCtx;
|
54
|
+
invokations: Invokaction[];
|
55
|
+
};
|
56
|
+
ctxWith(spanId: string, logger?: Logger): TraceCtxParam;
|
57
|
+
span<V extends (trace: TraceNode) => Promise<T> | T, T>(inSpanId: string | TraceCtxParam, fn: V): ReturnType<V>;
|
58
|
+
}
|
59
|
+
//# sourceMappingURL=tracer.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tracer.d.ts","sourceRoot":"","sources":["../../src/tracer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,M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AE,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,aAAa,EAAE,EAAE,EAAE,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;CAwDhH"}
|
package/ts/tracer.js
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
export class Metric {
|
2
|
+
constructor(path) {
|
3
|
+
this.path = path;
|
4
|
+
}
|
5
|
+
set(value) {
|
6
|
+
this.value = value;
|
7
|
+
}
|
8
|
+
add(value) {
|
9
|
+
if (typeof value === "number") {
|
10
|
+
if (this.value === undefined) {
|
11
|
+
this.value = 0;
|
12
|
+
}
|
13
|
+
this.value = (this.value + value);
|
14
|
+
}
|
15
|
+
else if (Array.isArray(value)) {
|
16
|
+
if (!Array.isArray(this.value)) {
|
17
|
+
this.value = [];
|
18
|
+
}
|
19
|
+
this.value.push(...value);
|
20
|
+
}
|
21
|
+
else {
|
22
|
+
throw new Error("add only support number or array");
|
23
|
+
}
|
24
|
+
}
|
25
|
+
}
|
26
|
+
export class Metrics {
|
27
|
+
constructor(tracenode) {
|
28
|
+
this.spanRefs = new Map();
|
29
|
+
this.tracenode = tracenode;
|
30
|
+
this.map = tracenode.ctx.metrics;
|
31
|
+
}
|
32
|
+
toJSON() {
|
33
|
+
const obj = {};
|
34
|
+
for (const [key, value] of this.map) {
|
35
|
+
obj[key] = value.value;
|
36
|
+
}
|
37
|
+
return obj;
|
38
|
+
}
|
39
|
+
get(ipath) {
|
40
|
+
const path = ipath.replace(/[/]+/g, "/").trim();
|
41
|
+
if (path.startsWith("/")) {
|
42
|
+
if (path.slice(1).length === 0) {
|
43
|
+
throw new Error(`Metrics path must contain value /:${path}`);
|
44
|
+
}
|
45
|
+
let metric = this.map.get(path);
|
46
|
+
if (!metric) {
|
47
|
+
metric = new Metric(path);
|
48
|
+
this.map.set(path, metric);
|
49
|
+
}
|
50
|
+
this.spanRefs.set(path, metric);
|
51
|
+
return metric;
|
52
|
+
}
|
53
|
+
else if (path.includes("/")) {
|
54
|
+
throw new Error(`Metrics path must start with /:${path}`);
|
55
|
+
}
|
56
|
+
const rootPath = this.tracenode.getRootPath();
|
57
|
+
return this.get(`${rootPath}/${path}`);
|
58
|
+
}
|
59
|
+
}
|
60
|
+
export class TraceNode {
|
61
|
+
static root(time, logger) {
|
62
|
+
return new TraceNode({
|
63
|
+
spanId: "root",
|
64
|
+
time,
|
65
|
+
logger,
|
66
|
+
metrics: new Map(),
|
67
|
+
parent: undefined,
|
68
|
+
});
|
69
|
+
}
|
70
|
+
constructor(ctx) {
|
71
|
+
this.childs = new Map();
|
72
|
+
this.invokations = [];
|
73
|
+
this.spanId = ctx.spanId;
|
74
|
+
this.ctx = ctx;
|
75
|
+
this.metrics = new Metrics(this);
|
76
|
+
}
|
77
|
+
getRootPath(rpath = []) {
|
78
|
+
if (!this.ctx.parent) {
|
79
|
+
return "/" + rpath.reverse().join("/");
|
80
|
+
}
|
81
|
+
return this.ctx.parent.getRootPath(rpath.concat(this.ctx.spanId));
|
82
|
+
}
|
83
|
+
invokes() {
|
84
|
+
const cleanCtx = Object.assign({}, this.ctx);
|
85
|
+
delete cleanCtx.parent;
|
86
|
+
delete cleanCtx.time;
|
87
|
+
delete cleanCtx.logger;
|
88
|
+
delete cleanCtx.metrics;
|
89
|
+
const spanRefs = this.metrics.toJSON.call({ map: this.metrics.spanRefs });
|
90
|
+
const metricsRefs = Object.keys(spanRefs).length > 0 ? { metricRefs: spanRefs } : {};
|
91
|
+
return Object.assign({ ctx: cleanCtx, invokations: this.invokations }, metricsRefs);
|
92
|
+
}
|
93
|
+
ctxWith(spanId, logger) {
|
94
|
+
const ctx = Object.assign(Object.assign({}, this.ctx), { spanId });
|
95
|
+
if (logger) {
|
96
|
+
ctx.logger = logger;
|
97
|
+
}
|
98
|
+
return ctx;
|
99
|
+
}
|
100
|
+
span(inSpanId, fn) {
|
101
|
+
let ctx;
|
102
|
+
if (typeof inSpanId === "string") {
|
103
|
+
ctx = Object.assign(Object.assign({}, this.ctx), { spanId: inSpanId, parent: this });
|
104
|
+
}
|
105
|
+
else {
|
106
|
+
ctx = Object.assign(Object.assign(Object.assign({}, this.ctx), inSpanId), { parent: this });
|
107
|
+
}
|
108
|
+
if (ctx.logger) {
|
109
|
+
ctx = Object.assign(Object.assign({}, ctx), ctx.logger.Attributes());
|
110
|
+
}
|
111
|
+
const spanId = ctx.spanId;
|
112
|
+
let spanTrace = this.childs.get(spanId);
|
113
|
+
if (!spanTrace) {
|
114
|
+
spanTrace = new TraceNode(ctx);
|
115
|
+
this.childs.set(spanId.toString(), spanTrace);
|
116
|
+
}
|
117
|
+
const invokation = {
|
118
|
+
start: this.ctx.time.Now().getTime(),
|
119
|
+
end: 0,
|
120
|
+
result: "success",
|
121
|
+
};
|
122
|
+
spanTrace.invokations.push(invokation);
|
123
|
+
try {
|
124
|
+
const possiblePromise = fn(spanTrace);
|
125
|
+
if (possiblePromise instanceof Promise) {
|
126
|
+
return possiblePromise
|
127
|
+
.then((v) => {
|
128
|
+
return v;
|
129
|
+
})
|
130
|
+
.catch((e) => {
|
131
|
+
invokation.result = "error";
|
132
|
+
throw e;
|
133
|
+
})
|
134
|
+
.finally(() => {
|
135
|
+
invokation.end = this.ctx.time.Now().getTime();
|
136
|
+
});
|
137
|
+
}
|
138
|
+
invokation.end = this.ctx.time.Now().getTime();
|
139
|
+
return possiblePromise;
|
140
|
+
}
|
141
|
+
catch (e) {
|
142
|
+
invokation.result = "error";
|
143
|
+
invokation.end = this.ctx.time.Now().getTime();
|
144
|
+
throw e;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
}
|
148
|
+
//# sourceMappingURL=tracer.js.map
|
package/ts/tracer.js.map
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tracer.js","sourceRoot":"","sources":["../../src/tracer.ts"],"names":[],"mappings":"AAyBA,MAAM,OAAO,MAAM;IAIjB,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,GAAG,CAAC,KAAQ;QACV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YAAY,OAAO,EAAE,CAAC;gBACvC,OAAO,eAAe;qBACnB,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;oBACV,OAAO,CAAC,CAAC;gBACX,CAAC,CAAC;qBACD,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;oBACX,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC;oBAC5B,MAAM,CAAC,CAAC;gBACV,CAAC,CAAC;qBACD,OAAO,CAAC,GAAG,EAAE;oBACZ,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;gBACjD,CAAC,CAAkB,CAAC;YACxB,CAAC;YACD,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;YAC/C,OAAO,eAAgC,CAAC;QAC1C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,UAAU,CAAC,MAAM,GAAG,OAAO,CAAC;YAC5B,UAAU,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC;YAC/C,MAAM,CAAC,CAAC;QACV,CAAC;IACH,CAAC;CACF"}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tracer.test.d.ts","sourceRoot":"","sources":["../../src/tracer.test.ts"],"names":[],"mappings":""}
|
@@ -0,0 +1,311 @@
|
|
1
|
+
import { WebSysAbstraction } from "./web/index.js";
|
2
|
+
import { TimeMode } from "./sys-abstraction.js";
|
3
|
+
import { TraceNode } from "./tracer.js";
|
4
|
+
import { MockLogger } from "./test/mock-logger.js";
|
5
|
+
describe("trace", () => {
|
6
|
+
let time;
|
7
|
+
let refTime;
|
8
|
+
let trace;
|
9
|
+
const logger = MockLogger().logger.With().Module("trace").Str("value", "important").Logger();
|
10
|
+
beforeEach(() => {
|
11
|
+
time = WebSysAbstraction({ TimeMode: TimeMode.STEP }).Time();
|
12
|
+
trace = TraceNode.root(time, logger);
|
13
|
+
refTime = WebSysAbstraction({ TimeMode: TimeMode.STEP }).Time();
|
14
|
+
});
|
15
|
+
it("a simple trace", () => {
|
16
|
+
var _a;
|
17
|
+
expect(trace.span("test", (trace) => {
|
18
|
+
const r1 = trace.span("test.1", () => {
|
19
|
+
return 1;
|
20
|
+
});
|
21
|
+
const r2 = trace.span("test.2", () => {
|
22
|
+
return 1;
|
23
|
+
});
|
24
|
+
return r1 + r2;
|
25
|
+
})).toBe(2);
|
26
|
+
const childs = Array.from(trace.childs.values());
|
27
|
+
expect(childs.map((v) => v.invokes())).toEqual([
|
28
|
+
{
|
29
|
+
ctx: {
|
30
|
+
module: "trace",
|
31
|
+
spanId: "test",
|
32
|
+
value: "important",
|
33
|
+
},
|
34
|
+
invokations: [
|
35
|
+
{
|
36
|
+
start: refTime.Now().getTime(),
|
37
|
+
result: "success",
|
38
|
+
end: refTime.Now(5).getTime(),
|
39
|
+
},
|
40
|
+
],
|
41
|
+
},
|
42
|
+
]);
|
43
|
+
const layered = Array.from(((_a = trace.childs.get("test")) === null || _a === void 0 ? void 0 : _a.childs.values()) || []);
|
44
|
+
refTime = WebSysAbstraction({ TimeMode: TimeMode.STEP }).Time();
|
45
|
+
expect(layered.map((v) => v.invokes())).toEqual([
|
46
|
+
{
|
47
|
+
ctx: {
|
48
|
+
module: "trace",
|
49
|
+
spanId: "test.1",
|
50
|
+
value: "important",
|
51
|
+
},
|
52
|
+
invokations: [
|
53
|
+
{
|
54
|
+
start: refTime.Now(2).getTime(),
|
55
|
+
result: "success",
|
56
|
+
end: refTime.Now().getTime(),
|
57
|
+
},
|
58
|
+
],
|
59
|
+
},
|
60
|
+
{
|
61
|
+
ctx: {
|
62
|
+
module: "trace",
|
63
|
+
spanId: "test.2",
|
64
|
+
value: "important",
|
65
|
+
},
|
66
|
+
invokations: [
|
67
|
+
{
|
68
|
+
start: refTime.Now().getTime(),
|
69
|
+
result: "success",
|
70
|
+
end: refTime.Now(1).getTime(),
|
71
|
+
},
|
72
|
+
],
|
73
|
+
},
|
74
|
+
]);
|
75
|
+
});
|
76
|
+
it("a async simple trace", async () => {
|
77
|
+
var _a, _b;
|
78
|
+
const log = (_a = trace.ctx.logger) === null || _a === void 0 ? void 0 : _a.With().Str("value", "test").Logger();
|
79
|
+
const ret = await trace.span(trace.ctxWith("test", log), async (trace) => {
|
80
|
+
var _a;
|
81
|
+
const r1 = trace.span(trace.ctxWith("test.1"), () => 1);
|
82
|
+
const log2 = (_a = trace.ctx.logger) === null || _a === void 0 ? void 0 : _a.With().Module("xxx").Str("r2", "test.2").Logger();
|
83
|
+
const r2 = (await trace.span(trace.ctxWith("test.2", log2), async () => {
|
84
|
+
time.Now();
|
85
|
+
await new Promise((resolve) => setTimeout(() => {
|
86
|
+
time.Now();
|
87
|
+
time.Now();
|
88
|
+
resolve();
|
89
|
+
}, 100));
|
90
|
+
return 1;
|
91
|
+
}));
|
92
|
+
return r1 + r2;
|
93
|
+
});
|
94
|
+
expect(ret).toBe(2);
|
95
|
+
const childs = Array.from(trace.childs.values());
|
96
|
+
const exp = childs.map((v) => v.invokes());
|
97
|
+
expect(exp).toEqual([
|
98
|
+
{
|
99
|
+
ctx: {
|
100
|
+
module: "trace",
|
101
|
+
spanId: "test",
|
102
|
+
value: "test",
|
103
|
+
},
|
104
|
+
invokations: [
|
105
|
+
{
|
106
|
+
start: refTime.Now().getTime(),
|
107
|
+
result: "success",
|
108
|
+
end: refTime.Now(8).getTime(),
|
109
|
+
},
|
110
|
+
],
|
111
|
+
},
|
112
|
+
]);
|
113
|
+
const layered = Array.from(((_b = trace.childs.get("test")) === null || _b === void 0 ? void 0 : _b.childs.values()) || []);
|
114
|
+
expect(layered.map((v) => v.invokes())).toEqual([
|
115
|
+
{
|
116
|
+
ctx: {
|
117
|
+
module: "trace",
|
118
|
+
spanId: "test.1",
|
119
|
+
value: "test",
|
120
|
+
},
|
121
|
+
invokations: [
|
122
|
+
{
|
123
|
+
result: "success",
|
124
|
+
start: refTime.Now(-2).getTime(),
|
125
|
+
end: refTime.Now().getTime(),
|
126
|
+
},
|
127
|
+
],
|
128
|
+
},
|
129
|
+
{
|
130
|
+
ctx: {
|
131
|
+
module: "xxx",
|
132
|
+
r2: "test.2",
|
133
|
+
spanId: "test.2",
|
134
|
+
value: "test",
|
135
|
+
},
|
136
|
+
invokations: [
|
137
|
+
{
|
138
|
+
start: refTime.Now().getTime(),
|
139
|
+
end: refTime.Now(4).getTime(),
|
140
|
+
result: "success",
|
141
|
+
},
|
142
|
+
],
|
143
|
+
},
|
144
|
+
]);
|
145
|
+
});
|
146
|
+
it("a async exception trace", async () => {
|
147
|
+
var _a;
|
148
|
+
const ret = await trace.span("test", async (trace) => {
|
149
|
+
let r1 = 0;
|
150
|
+
let r2 = 0;
|
151
|
+
for (let i = 0; i < 3; i++) {
|
152
|
+
try {
|
153
|
+
r1 += trace.span("test.1", (trace) => {
|
154
|
+
if (i % 2) {
|
155
|
+
throw new Error("test.1");
|
156
|
+
}
|
157
|
+
trace.metrics.get("i.1").add([i]);
|
158
|
+
return 1;
|
159
|
+
});
|
160
|
+
}
|
161
|
+
catch (e) {
|
162
|
+
if (i % 2) {
|
163
|
+
expect(e.message).toEqual("test.1");
|
164
|
+
}
|
165
|
+
else {
|
166
|
+
assert(false, "should not happen");
|
167
|
+
}
|
168
|
+
}
|
169
|
+
try {
|
170
|
+
r2 += await trace.span("test.2", async (trace) => {
|
171
|
+
time.Now();
|
172
|
+
await new Promise((resolve, reject) => setTimeout(() => {
|
173
|
+
time.Now();
|
174
|
+
time.Now();
|
175
|
+
if (i % 2) {
|
176
|
+
trace.metrics.get("i.2").add(i);
|
177
|
+
resolve();
|
178
|
+
}
|
179
|
+
else {
|
180
|
+
reject("test.2");
|
181
|
+
}
|
182
|
+
}, 10));
|
183
|
+
return 1;
|
184
|
+
});
|
185
|
+
}
|
186
|
+
catch (e) {
|
187
|
+
if (i % 2) {
|
188
|
+
assert(false, "should not happen");
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
expect(e).toEqual("test.2");
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
195
|
+
return r1 + r2;
|
196
|
+
});
|
197
|
+
expect(ret).toBe(3);
|
198
|
+
expect(trace.metrics.toJSON()).toEqual({
|
199
|
+
"/test/test.1/i.1": [0, 2],
|
200
|
+
"/test/test.2/i.2": 1,
|
201
|
+
});
|
202
|
+
const childs = Array.from(trace.childs.values());
|
203
|
+
const exp = childs.map((v) => v.invokes());
|
204
|
+
expect(exp).toEqual([
|
205
|
+
{
|
206
|
+
ctx: {
|
207
|
+
module: "trace",
|
208
|
+
spanId: "test",
|
209
|
+
value: "important",
|
210
|
+
},
|
211
|
+
invokations: [
|
212
|
+
{
|
213
|
+
start: refTime.Now(1).getTime(),
|
214
|
+
end: refTime.Now(22).getTime(),
|
215
|
+
result: "success",
|
216
|
+
},
|
217
|
+
],
|
218
|
+
},
|
219
|
+
]);
|
220
|
+
const layered = Array.from(((_a = trace.childs.get("test")) === null || _a === void 0 ? void 0 : _a.childs.values()) || []);
|
221
|
+
expect(layered.map((v) => v.invokes())).toEqual([
|
222
|
+
{
|
223
|
+
ctx: {
|
224
|
+
module: "trace",
|
225
|
+
spanId: "test.1",
|
226
|
+
value: "important",
|
227
|
+
},
|
228
|
+
invokations: [
|
229
|
+
{
|
230
|
+
start: refTime.Now(-2).getTime(),
|
231
|
+
end: refTime.Now().getTime(),
|
232
|
+
result: "success",
|
233
|
+
},
|
234
|
+
{
|
235
|
+
start: refTime.Now(-9).getTime(),
|
236
|
+
end: refTime.Now().getTime(),
|
237
|
+
result: "error",
|
238
|
+
},
|
239
|
+
{
|
240
|
+
start: refTime.Now(-16).getTime(),
|
241
|
+
end: refTime.Now().getTime(),
|
242
|
+
result: "success",
|
243
|
+
},
|
244
|
+
],
|
245
|
+
metricRefs: {
|
246
|
+
"/test/test.1/i.1": [0, 2],
|
247
|
+
},
|
248
|
+
},
|
249
|
+
{
|
250
|
+
ctx: {
|
251
|
+
module: "trace",
|
252
|
+
spanId: "test.2",
|
253
|
+
value: "important",
|
254
|
+
},
|
255
|
+
invokations: [
|
256
|
+
{
|
257
|
+
start: refTime.Now(-4).getTime(),
|
258
|
+
end: refTime.Now(4).getTime(),
|
259
|
+
result: "error",
|
260
|
+
},
|
261
|
+
{
|
262
|
+
start: refTime.Now(-11).getTime(),
|
263
|
+
end: refTime.Now(4).getTime(),
|
264
|
+
result: "success",
|
265
|
+
},
|
266
|
+
{
|
267
|
+
start: refTime.Now(-18).getTime(),
|
268
|
+
end: refTime.Now(4).getTime(),
|
269
|
+
result: "error",
|
270
|
+
},
|
271
|
+
],
|
272
|
+
metricRefs: {
|
273
|
+
"/test/test.2/i.2": 1,
|
274
|
+
},
|
275
|
+
},
|
276
|
+
]);
|
277
|
+
});
|
278
|
+
});
|
279
|
+
describe("metrics", () => {
|
280
|
+
let time;
|
281
|
+
let trace;
|
282
|
+
beforeEach(() => {
|
283
|
+
time = WebSysAbstraction({ TimeMode: TimeMode.STEP }).Time();
|
284
|
+
trace = TraceNode.root(time);
|
285
|
+
});
|
286
|
+
it("a simple metrics", () => {
|
287
|
+
["/test", "test", "/test/wurst", "bla"].forEach((path) => {
|
288
|
+
const abs = path.startsWith("/") ? path : "/" + path;
|
289
|
+
expect(trace.metrics.get(path).path).toBe(abs);
|
290
|
+
expect(trace.metrics.get(path).value).toBeFalsy();
|
291
|
+
trace.metrics.get(path).add(4711);
|
292
|
+
expect(trace.metrics.get(path).value).toBe(4711);
|
293
|
+
trace.metrics.get(path).set(undefined);
|
294
|
+
});
|
295
|
+
});
|
296
|
+
it("create metrics path", () => {
|
297
|
+
trace.span("test", (trace) => {
|
298
|
+
trace.span("test.1", (trace) => {
|
299
|
+
trace.metrics.get("m1.1").add(1);
|
300
|
+
trace.metrics.get("/test/test.1/m1.1").add(1);
|
301
|
+
expect(trace.metrics.get("m1.1").path).toBe("/test/test.1/m1.1");
|
302
|
+
expect(trace.metrics.get("m1.1").value).toBe(2);
|
303
|
+
});
|
304
|
+
});
|
305
|
+
});
|
306
|
+
it("typed span promise or literal", async () => {
|
307
|
+
expect(trace.span("test", () => "1")).toBe("1");
|
308
|
+
expect(await trace.span("test", async () => 1)).toBe(1);
|
309
|
+
});
|
310
|
+
});
|
311
|
+
//# sourceMappingURL=tracer.test.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"tracer.test.js","sourceRoot":"","sources":["../../src/tracer.test.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACrB,IAAI,IAAU,CAAC;IACf,IAAI,OAAa,CAAC;IAClB,IAAI,KAAgB,CAAC;IACrB,MAAM,MAAM,GAAG,UAAU,EAAE,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,MAAM,EAAE,CAAC;IAC7F,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;QAC7D,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACrC,OAAO,GAAG,iBAAiB,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IAClE,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;;QACxB,MAAM,CACJ,KAAK,CAAC,IAAI,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C,CAAC;YAClD,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,+BAA+B,EAAE,KAAK,IAAI,EAAE;QAC7C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAChD,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export interface TxtEnDecoder {
|
2
|
+
encode(str: string): Uint8Array;
|
3
|
+
decode(data: Uint8Array): string;
|
4
|
+
}
|
5
|
+
export declare class Utf8EnDecoder implements TxtEnDecoder {
|
6
|
+
encode(str: string): Uint8Array;
|
7
|
+
decode(data: Uint8Array): string;
|
8
|
+
}
|
9
|
+
export declare function Utf8EnDecoderSingleton(): TxtEnDecoder;
|
10
|
+
//# sourceMappingURL=txt-en-decoder.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"txt-en-decoder.d.ts","sourceRoot":"","sources":["../../src/txt-en-decoder.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAAC;IAChC,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAKD,qBAAa,aAAc,YAAW,YAAY;IAChD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU;IAG/B,MAAM,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM;CAGjC;AAGD,wBAAgB,sBAAsB,IAAI,YAAY,CAErD"}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
const encoder = new TextEncoder();
|
2
|
+
const decoder = new TextDecoder();
|
3
|
+
export class Utf8EnDecoder {
|
4
|
+
encode(str) {
|
5
|
+
return encoder.encode(str);
|
6
|
+
}
|
7
|
+
decode(data) {
|
8
|
+
return decoder.decode(data);
|
9
|
+
}
|
10
|
+
}
|
11
|
+
const utf8EnDecoder = new Utf8EnDecoder();
|
12
|
+
export function Utf8EnDecoderSingleton() {
|
13
|
+
return utf8EnDecoder;
|
14
|
+
}
|
15
|
+
//# sourceMappingURL=txt-en-decoder.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"txt-en-decoder.js","sourceRoot":"","sources":["../../src/txt-en-decoder.ts"],"names":[],"mappings":"AAKA,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAClC,MAAM,OAAO,GAAG,IAAI,WAAW,EAAE,CAAC;AAElC,MAAM,OAAO,aAAa;IACxB,MAAM,CAAC,GAAW;QAChB,OAAO,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IACD,MAAM,CAAC,IAAgB;QACrB,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;CACF;AAED,MAAM,aAAa,GAAG,IAAI,aAAa,EAAE,CAAC;AAC1C,MAAM,UAAU,sBAAsB;IACpC,OAAO,aAAa,CAAC;AACvB,CAAC"}
|