@adviser/cement 0.1.10 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. package/base_sys_abstraction-BCdXJHNa.d.ts +21 -0
  2. package/base_sys_abstraction-BYZvxqsW.d.cts +21 -0
  3. package/chunk-J2IM7FHM.js +65 -0
  4. package/chunk-J2IM7FHM.js.map +1 -0
  5. package/chunk-MWAFFTM4.js +82 -0
  6. package/chunk-MWAFFTM4.js.map +1 -0
  7. package/chunk-PZTL4UNG.js +233 -0
  8. package/chunk-PZTL4UNG.js.map +1 -0
  9. package/index.cjs +987 -0
  10. package/index.cjs.map +1 -0
  11. package/index.d.cts +196 -0
  12. package/index.d.ts +196 -10
  13. package/index.js +611 -25
  14. package/index.js.map +1 -1
  15. package/node/index.cjs +436 -0
  16. package/node/index.cjs.map +1 -0
  17. package/node/index.d.cts +47 -0
  18. package/node/index.d.ts +47 -4
  19. package/node/index.js +215 -17
  20. package/node/index.js.map +1 -1
  21. package/package.json +39 -11
  22. package/sys_abstraction-CjljYIkv.d.cts +65 -0
  23. package/sys_abstraction-CjljYIkv.d.ts +65 -0
  24. package/utils/index.cjs +270 -0
  25. package/utils/index.cjs.map +1 -0
  26. package/utils/index.d.cts +33 -0
  27. package/utils/index.d.ts +33 -6
  28. package/utils/index.js +232 -20
  29. package/utils/index.js.map +1 -1
  30. package/web/index.cjs +286 -0
  31. package/web/index.cjs.map +1 -0
  32. package/web/index.d.cts +6 -0
  33. package/web/index.d.ts +6 -2
  34. package/web/index.js +7 -16
  35. package/web/index.js.map +1 -1
  36. package/base_sys_abstraction.d.ts +0 -79
  37. package/base_sys_abstraction.d.ts.map +0 -1
  38. package/base_sys_abstraction.js +0 -186
  39. package/base_sys_abstraction.js.map +0 -1
  40. package/base_sys_abstraction.test.d.ts +0 -2
  41. package/base_sys_abstraction.test.d.ts.map +0 -1
  42. package/base_sys_abstraction.test.js +0 -77
  43. package/base_sys_abstraction.test.js.map +0 -1
  44. package/file_service.d.ts +0 -18
  45. package/file_service.d.ts.map +0 -1
  46. package/file_service.js +0 -3
  47. package/file_service.js.map +0 -1
  48. package/index.d.ts.map +0 -1
  49. package/logger.d.ts +0 -36
  50. package/logger.d.ts.map +0 -1
  51. package/logger.js +0 -11
  52. package/logger.js.map +0 -1
  53. package/logger.test.d.ts +0 -2
  54. package/logger.test.d.ts.map +0 -1
  55. package/logger.test.js +0 -362
  56. package/logger.test.js.map +0 -1
  57. package/logger_impl.d.ts +0 -64
  58. package/logger_impl.d.ts.map +0 -1
  59. package/logger_impl.js +0 -330
  60. package/logger_impl.js.map +0 -1
  61. package/node/index.d.ts.map +0 -1
  62. package/node/mock_file_service.d.ts +0 -11
  63. package/node/mock_file_service.d.ts.map +0 -1
  64. package/node/mock_file_service.js +0 -37
  65. package/node/mock_file_service.js.map +0 -1
  66. package/node/mock_file_service.test.d.ts +0 -2
  67. package/node/mock_file_service.test.d.ts.map +0 -1
  68. package/node/mock_file_service.test.js +0 -19
  69. package/node/mock_file_service.test.js.map +0 -1
  70. package/node/node_file_service.d.ts +0 -16
  71. package/node/node_file_service.d.ts.map +0 -1
  72. package/node/node_file_service.js +0 -84
  73. package/node/node_file_service.js.map +0 -1
  74. package/node/node_sys_abstraction.d.ts +0 -21
  75. package/node/node_sys_abstraction.d.ts.map +0 -1
  76. package/node/node_sys_abstraction.js +0 -101
  77. package/node/node_sys_abstraction.js.map +0 -1
  78. package/node/node_sys_abstraction.test.d.ts +0 -2
  79. package/node/node_sys_abstraction.test.d.ts.map +0 -1
  80. package/node/node_sys_abstraction.test.js +0 -57
  81. package/node/node_sys_abstraction.test.js.map +0 -1
  82. package/option.d.ts +0 -25
  83. package/option.d.ts.map +0 -1
  84. package/option.js +0 -53
  85. package/option.js.map +0 -1
  86. package/result.d.ts +0 -31
  87. package/result.d.ts.map +0 -1
  88. package/result.js +0 -69
  89. package/result.js.map +0 -1
  90. package/result.test.d.ts +0 -2
  91. package/result.test.d.ts.map +0 -1
  92. package/result.test.js +0 -39
  93. package/result.test.js.map +0 -1
  94. package/sys_abstraction.d.ts +0 -35
  95. package/sys_abstraction.d.ts.map +0 -1
  96. package/sys_abstraction.js +0 -35
  97. package/sys_abstraction.js.map +0 -1
  98. package/test/log_collector.d.ts +0 -22
  99. package/test/log_collector.d.ts.map +0 -1
  100. package/test/log_collector.js +0 -65
  101. package/test/log_collector.js.map +0 -1
  102. package/test/mock_logger.d.ts +0 -13
  103. package/test/mock_logger.d.ts.map +0 -1
  104. package/test/mock_logger.js +0 -30
  105. package/test/mock_logger.js.map +0 -1
  106. package/test/mock_logger.test.d.ts +0 -2
  107. package/test/mock_logger.test.d.ts.map +0 -1
  108. package/test/mock_logger.test.js +0 -49
  109. package/test/mock_logger.test.js.map +0 -1
  110. package/test/test-exit-handler.d.ts +0 -1
  111. package/test/test-exit-handler.d.ts.map +0 -1
  112. package/test/test-exit-handler.js +0 -76
  113. package/test/test-exit-handler.js.map +0 -1
  114. package/time.d.ts +0 -13
  115. package/time.d.ts.map +0 -1
  116. package/time.js +0 -18
  117. package/time.js.map +0 -1
  118. package/utils/index.d.ts.map +0 -1
  119. package/utils/rebuffer.d.ts +0 -3
  120. package/utils/rebuffer.d.ts.map +0 -1
  121. package/utils/rebuffer.js +0 -65
  122. package/utils/rebuffer.js.map +0 -1
  123. package/utils/rebuffer.test.d.ts +0 -2
  124. package/utils/rebuffer.test.d.ts.map +0 -1
  125. package/utils/rebuffer.test.js +0 -79
  126. package/utils/rebuffer.test.js.map +0 -1
  127. package/utils/stream2string.d.ts +0 -3
  128. package/utils/stream2string.d.ts.map +0 -1
  129. package/utils/stream2string.js +0 -53
  130. package/utils/stream2string.js.map +0 -1
  131. package/utils/stream2string.test.d.ts +0 -2
  132. package/utils/stream2string.test.d.ts.map +0 -1
  133. package/utils/stream2string.test.js +0 -31
  134. package/utils/stream2string.test.js.map +0 -1
  135. package/utils/stream_map.d.ts +0 -9
  136. package/utils/stream_map.d.ts.map +0 -1
  137. package/utils/stream_map.js +0 -67
  138. package/utils/stream_map.js.map +0 -1
  139. package/utils/stream_map.test.d.ts +0 -2
  140. package/utils/stream_map.test.d.ts.map +0 -1
  141. package/utils/stream_map.test.js +0 -89
  142. package/utils/stream_map.test.js.map +0 -1
  143. package/utils/stream_test_helper.d.ts +0 -15
  144. package/utils/stream_test_helper.d.ts.map +0 -1
  145. package/utils/stream_test_helper.js +0 -42
  146. package/utils/stream_test_helper.js.map +0 -1
  147. package/utils/string2stream.d.ts +0 -3
  148. package/utils/string2stream.d.ts.map +0 -1
  149. package/utils/string2stream.js +0 -18
  150. package/utils/string2stream.js.map +0 -1
  151. package/utils/string2stream.test.d.ts +0 -2
  152. package/utils/string2stream.test.d.ts.map +0 -1
  153. package/utils/string2stream.test.js +0 -9
  154. package/utils/string2stream.test.js.map +0 -1
  155. package/web/index.d.ts.map +0 -1
  156. package/web/web_sys_abstraction.d.ts +0 -4
  157. package/web/web_sys_abstraction.d.ts.map +0 -1
  158. package/web/web_sys_abstraction.js +0 -65
  159. package/web/web_sys_abstraction.js.map +0 -1
package/index.js CHANGED
@@ -1,26 +1,612 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./file_service"), exports);
18
- __exportStar(require("./logger_impl"), exports);
19
- __exportStar(require("./logger"), exports);
20
- __exportStar(require("./sys_abstraction"), exports);
21
- __exportStar(require("./time"), exports);
22
- __exportStar(require("./test/log_collector"), exports);
23
- __exportStar(require("./test/mock_logger"), exports);
24
- __exportStar(require("./result"), exports);
25
- __exportStar(require("./option"), exports);
1
+ import {
2
+ WebSysAbstraction
3
+ } from "./chunk-MWAFFTM4.js";
4
+ import {
5
+ IDMode,
6
+ RandomMode,
7
+ String2TimeMode,
8
+ Time,
9
+ TimeMode,
10
+ TimeUnits
11
+ } from "./chunk-PZTL4UNG.js";
12
+ import {
13
+ __privateAdd,
14
+ __privateGet,
15
+ __privateSet,
16
+ __spreadValues,
17
+ __yieldStar
18
+ } from "./chunk-J2IM7FHM.js";
19
+
20
+ // src/logger.ts
21
+ var Level = /* @__PURE__ */ ((Level2) => {
22
+ Level2["WARN"] = "warn";
23
+ Level2["DEBUG"] = "debug";
24
+ Level2["INFO"] = "info";
25
+ Level2["ERROR"] = "error";
26
+ return Level2;
27
+ })(Level || {});
28
+
29
+ // src/logger_impl.ts
30
+ var encoder = new TextEncoder();
31
+ var LevelHandlerImpl = class {
32
+ constructor() {
33
+ this._globalLevels = /* @__PURE__ */ new Set(["info" /* INFO */, "error" /* ERROR */, "warn" /* WARN */]);
34
+ this._modules = /* @__PURE__ */ new Map();
35
+ }
36
+ enableLevel(level, ...modules) {
37
+ if (modules.length == 0) {
38
+ this._globalLevels.add(level);
39
+ return;
40
+ }
41
+ this.forModules(
42
+ level,
43
+ (p) => {
44
+ this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, level]));
45
+ },
46
+ ...modules
47
+ );
48
+ }
49
+ disableLevel(level, ...modules) {
50
+ if (modules.length == 0) {
51
+ this._globalLevels.delete(level);
52
+ return;
53
+ }
54
+ this.forModules(
55
+ level,
56
+ (p) => {
57
+ this._modules.delete(p);
58
+ },
59
+ ...modules
60
+ );
61
+ }
62
+ forModules(level, fnAction, ...modules) {
63
+ for (const m of modules.flat()) {
64
+ const parts = m.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
65
+ for (const p of parts) {
66
+ fnAction(p);
67
+ }
68
+ }
69
+ }
70
+ setDebug(...modules) {
71
+ this.forModules(
72
+ "debug" /* DEBUG */,
73
+ (p) => {
74
+ this._modules.set(p, /* @__PURE__ */ new Set([...this._globalLevels, "debug" /* DEBUG */]));
75
+ },
76
+ ...modules
77
+ );
78
+ }
79
+ isEnabled(ilevel, module) {
80
+ const level = ilevel;
81
+ if (module !== void 0) {
82
+ const levels = this._modules.get(module);
83
+ if (levels && levels.has(level)) {
84
+ return true;
85
+ }
86
+ }
87
+ if (level === void 0) {
88
+ return true;
89
+ }
90
+ return this._globalLevels.has(level);
91
+ }
92
+ };
93
+ var levelSingleton = new LevelHandlerImpl();
94
+ var LogWriter = class {
95
+ constructor(out) {
96
+ this._toFlush = [];
97
+ this._flushIsRunning = false;
98
+ this._flushDoneFns = Array();
99
+ this._out = out;
100
+ }
101
+ write(encoded) {
102
+ const my = async () => {
103
+ try {
104
+ const writer = this._out.getWriter();
105
+ await writer.ready;
106
+ await writer.write(encoded);
107
+ await writer.releaseLock();
108
+ } catch (err) {
109
+ console.error("Chunk error:", err);
110
+ }
111
+ };
112
+ this._toFlush.push(my);
113
+ this._flush();
114
+ }
115
+ _flush(toFlush = void 0, done) {
116
+ if (done) {
117
+ this._flushDoneFns.push(done);
118
+ }
119
+ if (this._toFlush.length == 0) {
120
+ this._flushIsRunning = false;
121
+ this._flushDoneFns.forEach((fn) => fn());
122
+ this._flushDoneFns = [];
123
+ return;
124
+ }
125
+ if (!toFlush && this._toFlush.length == 1 && !this._flushIsRunning) {
126
+ this._flushIsRunning = true;
127
+ } else if (!toFlush) {
128
+ return;
129
+ }
130
+ const my = this._toFlush.shift();
131
+ my == null ? void 0 : my().finally(() => {
132
+ this._flush(this._toFlush);
133
+ });
134
+ }
135
+ };
136
+ var LoggerImpl = class _LoggerImpl {
137
+ // readonly _id: string = "logger-" + Math.random().toString(36)
138
+ constructor(params) {
139
+ this._attributes = {};
140
+ if (!params) {
141
+ params = {};
142
+ }
143
+ if (!params.sys) {
144
+ this._sys = WebSysAbstraction();
145
+ } else {
146
+ this._sys = params.sys;
147
+ }
148
+ if (params.logWriter) {
149
+ this._logWriter = params.logWriter;
150
+ } else {
151
+ if (!params.out) {
152
+ this._logWriter = new LogWriter(this._sys.Stdout());
153
+ } else {
154
+ this._logWriter = new LogWriter(params.out);
155
+ }
156
+ }
157
+ if (!params.withAttributes) {
158
+ this._withAttributes = {};
159
+ } else {
160
+ this._withAttributes = __spreadValues({}, params.withAttributes);
161
+ }
162
+ this._attributes = __spreadValues({}, this._withAttributes);
163
+ if (params.levelHandler) {
164
+ this._levelHandler = params.levelHandler;
165
+ } else {
166
+ this._levelHandler = levelSingleton;
167
+ }
168
+ }
169
+ EnableLevel(level, ...modules) {
170
+ this._levelHandler.enableLevel(level, ...modules);
171
+ return this;
172
+ }
173
+ DisableLevel(level, ...modules) {
174
+ this._levelHandler.disableLevel(level, ...modules);
175
+ return this;
176
+ }
177
+ Module(key) {
178
+ this._attributes["module"] = key;
179
+ this._withAttributes["module"] = key;
180
+ return this;
181
+ }
182
+ SetDebug(...modules) {
183
+ this._levelHandler.setDebug(...modules);
184
+ return this;
185
+ }
186
+ Timestamp() {
187
+ this._attributes["ts"] = this._sys.Time().Now().toISOString();
188
+ return this;
189
+ }
190
+ Warn() {
191
+ this._attributes["level"] = "warn" /* WARN */;
192
+ return this;
193
+ }
194
+ Log() {
195
+ return this;
196
+ }
197
+ Debug() {
198
+ this._attributes["level"] = "debug" /* DEBUG */;
199
+ return this;
200
+ }
201
+ Error() {
202
+ this._attributes["level"] = "error" /* ERROR */;
203
+ return this;
204
+ }
205
+ Info() {
206
+ this._attributes["level"] = "info" /* INFO */;
207
+ return this;
208
+ }
209
+ Err(err) {
210
+ if (err instanceof Error) {
211
+ this._attributes["error"] = err.message;
212
+ } else {
213
+ this._attributes["error"] = "" + err;
214
+ }
215
+ return this;
216
+ }
217
+ WithLevel(l) {
218
+ this._attributes["level"] = l;
219
+ return this;
220
+ }
221
+ Str(key, value) {
222
+ this._attributes[key] = value;
223
+ return this;
224
+ }
225
+ Any(key, value) {
226
+ this._attributes[key] = value;
227
+ return this;
228
+ }
229
+ Dur(key, nsec) {
230
+ this._attributes[key] = `${nsec}ms`;
231
+ return this;
232
+ }
233
+ Uint64(key, value) {
234
+ this._attributes[key] = value;
235
+ return this;
236
+ }
237
+ async Flush() {
238
+ return new Promise((resolve) => {
239
+ this._logWriter._flush(void 0, resolve);
240
+ });
241
+ }
242
+ With() {
243
+ return new WithLoggerBuilder(
244
+ new _LoggerImpl({
245
+ logWriter: this._logWriter,
246
+ sys: this._sys,
247
+ levelHandler: this._levelHandler,
248
+ withAttributes: __spreadValues({
249
+ module: this._attributes["module"]
250
+ }, this._withAttributes)
251
+ })
252
+ );
253
+ }
254
+ _resetAttributes(fn) {
255
+ const ret = fn();
256
+ Object.keys(this._attributes).forEach((key) => {
257
+ delete this._attributes[key];
258
+ });
259
+ Object.assign(this._attributes, this._withAttributes);
260
+ return ret;
261
+ }
262
+ Msg(...args) {
263
+ const error = this._resetAttributes(() => {
264
+ const doWrite = this._levelHandler.isEnabled(this._attributes["level"], this._attributes["module"]);
265
+ this._attributes["msg"] = args.join(" ");
266
+ if (typeof this._attributes["msg"] === "string" && !this._attributes["msg"].trim().length) {
267
+ delete this._attributes["msg"];
268
+ }
269
+ if (this._attributes["ts"] === "ETERNITY") {
270
+ this.Timestamp();
271
+ }
272
+ const str = JSON.stringify(this._attributes);
273
+ if (doWrite) {
274
+ const encoded = encoder.encode(str + "\n");
275
+ this._logWriter.write(encoded);
276
+ }
277
+ return new Error(str);
278
+ });
279
+ return {
280
+ AsError: () => error
281
+ };
282
+ }
283
+ };
284
+ var WithLoggerBuilder = class {
285
+ constructor(li) {
286
+ this._li = li;
287
+ }
288
+ Logger() {
289
+ Object.assign(this._li._withAttributes, this._li._attributes);
290
+ console.log(`Logger:${JSON.stringify([...this._li._levelHandler._globalLevels])}`);
291
+ return this._li;
292
+ }
293
+ EnableLevel(level, ...modules) {
294
+ this._li._levelHandler.enableLevel(level, ...modules);
295
+ return this;
296
+ }
297
+ DisableLevel(level, ...modules) {
298
+ this._li._levelHandler.enableLevel(level, ...modules);
299
+ return this;
300
+ }
301
+ Module(key) {
302
+ this._li.Module(key);
303
+ return this;
304
+ }
305
+ SetDebug(...modules) {
306
+ this._li.SetDebug(...modules);
307
+ return this;
308
+ }
309
+ Str(key, value) {
310
+ this._li.Str(key, value);
311
+ return this;
312
+ }
313
+ Log() {
314
+ this._li.Log();
315
+ return this;
316
+ }
317
+ WithLevel(level) {
318
+ this._li.WithLevel(level);
319
+ return this;
320
+ }
321
+ Error() {
322
+ this._li.Error();
323
+ return this;
324
+ }
325
+ Warn() {
326
+ this._li.Error();
327
+ return this;
328
+ }
329
+ Debug() {
330
+ this._li.Debug();
331
+ return this;
332
+ }
333
+ Err(err) {
334
+ this._li.Err(err);
335
+ return this;
336
+ }
337
+ Info() {
338
+ this._li.Info();
339
+ return this;
340
+ }
341
+ Timestamp() {
342
+ this._li._attributes["ts"] = "ETERNITY";
343
+ return this;
344
+ }
345
+ Any(key, value) {
346
+ this._li.Any(key, value);
347
+ return this;
348
+ }
349
+ Dur(key, nsec) {
350
+ this._li.Dur(key, nsec);
351
+ return this;
352
+ }
353
+ Uint64(key, value) {
354
+ this._li.Uint64(key, value);
355
+ return this;
356
+ }
357
+ };
358
+
359
+ // src/test/log_collector.ts
360
+ var LogWriter2 = class {
361
+ constructor() {
362
+ this._bufferArr = [];
363
+ this.desiredSize = null;
364
+ this.ready = Promise.resolve(void 0);
365
+ this._resolveClosed = () => {
366
+ };
367
+ this.closed = new Promise((resolve) => {
368
+ this._resolveClosed = resolve;
369
+ });
370
+ }
371
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars, @typescript-eslint/no-explicit-any
372
+ abort(reason) {
373
+ throw new Error("Method not implemented.");
374
+ }
375
+ close() {
376
+ this._resolveClosed();
377
+ return Promise.resolve(void 0);
378
+ }
379
+ releaseLock() {
380
+ }
381
+ write(chunk) {
382
+ chunk && this._bufferArr.push(chunk);
383
+ return Promise.resolve(void 0);
384
+ }
385
+ };
386
+ var LogCollector = class {
387
+ constructor() {
388
+ this.locked = false;
389
+ }
390
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
391
+ abort(reason) {
392
+ throw new Error("Method not implemented.");
393
+ }
394
+ async close() {
395
+ if (this._writer) {
396
+ const ret = await this._writer.close();
397
+ this._writer = void 0;
398
+ return ret;
399
+ }
400
+ return Promise.resolve(void 0);
401
+ }
402
+ getWriter() {
403
+ if (!this._writer) {
404
+ this._writer = new LogWriter2();
405
+ }
406
+ return this._writer;
407
+ }
408
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
409
+ Logs() {
410
+ if (!this._writer) {
411
+ return [];
412
+ }
413
+ const jsonNlStr = new TextDecoder().decode(
414
+ new Uint8Array(
415
+ function* (res) {
416
+ for (const x of res) {
417
+ yield* __yieldStar(x);
418
+ }
419
+ }(this._writer._bufferArr)
420
+ )
421
+ );
422
+ const splitStr = jsonNlStr.split("\n");
423
+ const filterStr = splitStr.filter((a) => a.length);
424
+ const mapStr = filterStr.map((a) => JSON.parse(a));
425
+ return mapStr;
426
+ }
427
+ };
428
+
429
+ // src/test/mock_logger.ts
430
+ function MockLogger(params) {
431
+ const lc = new LogCollector();
432
+ let modNames = ["MockLogger"];
433
+ if (typeof (params == null ? void 0 : params.moduleName) === "string") {
434
+ modNames = [params == null ? void 0 : params.moduleName];
435
+ } else if (Array.isArray(params == null ? void 0 : params.moduleName)) {
436
+ modNames = [...params.moduleName, ...modNames];
437
+ }
438
+ const logger = new LoggerImpl({
439
+ out: lc,
440
+ sys: params == null ? void 0 : params.sys,
441
+ levelHandler: new LevelHandlerImpl()
442
+ }).With().Module(modNames[0]).Logger();
443
+ !(params == null ? void 0 : params.disableDebug) && logger.SetDebug(...modNames);
444
+ return {
445
+ logCollector: lc,
446
+ logger
447
+ };
448
+ }
449
+
450
+ // src/result.ts
451
+ var Result = class _Result {
452
+ static Ok(t) {
453
+ return new ResultOK(t);
454
+ }
455
+ static Err(t) {
456
+ if (typeof t === "string") {
457
+ return new ResultError(new Error(t));
458
+ }
459
+ return new ResultError(t);
460
+ }
461
+ static Is(t) {
462
+ return t instanceof _Result;
463
+ }
464
+ isOk() {
465
+ return this.is_ok();
466
+ }
467
+ isErr() {
468
+ return this.is_err();
469
+ }
470
+ Ok() {
471
+ return this.unwrap();
472
+ }
473
+ Err() {
474
+ return this.unwrap_err();
475
+ }
476
+ };
477
+ var ResultOK = class extends Result {
478
+ constructor(t) {
479
+ super();
480
+ this._t = t;
481
+ }
482
+ is_ok() {
483
+ return true;
484
+ }
485
+ is_err() {
486
+ return false;
487
+ }
488
+ unwrap_err() {
489
+ throw new Error("Result is Ok");
490
+ }
491
+ unwrap() {
492
+ return this._t;
493
+ }
494
+ };
495
+ var ResultError = class extends Result {
496
+ constructor(t) {
497
+ super();
498
+ this._error = t;
499
+ }
500
+ is_ok() {
501
+ return false;
502
+ }
503
+ is_err() {
504
+ return true;
505
+ }
506
+ unwrap() {
507
+ throw new Error(`Result is Err: ${this._error}`);
508
+ }
509
+ unwrap_err() {
510
+ return this._error;
511
+ }
512
+ };
513
+
514
+ // src/option.ts
515
+ var Option = class _Option {
516
+ static Some(t) {
517
+ return new Some(t);
518
+ }
519
+ static None() {
520
+ return new None();
521
+ }
522
+ static Is(t) {
523
+ return t instanceof _Option;
524
+ }
525
+ IsNone() {
526
+ return this.is_none();
527
+ }
528
+ IsSome() {
529
+ return this.is_some();
530
+ }
531
+ Unwrap() {
532
+ return this.unwrap();
533
+ }
534
+ };
535
+ var Some = class extends Option {
536
+ constructor(_t) {
537
+ super();
538
+ this._t = _t;
539
+ }
540
+ is_none() {
541
+ return false;
542
+ }
543
+ is_some() {
544
+ return true;
545
+ }
546
+ unwrap() {
547
+ return this._t;
548
+ }
549
+ };
550
+ var None = class extends Option {
551
+ is_none() {
552
+ return true;
553
+ }
554
+ is_some() {
555
+ return false;
556
+ }
557
+ unwrap() {
558
+ throw new Error("None.unwrap");
559
+ }
560
+ };
561
+
562
+ // src/future.ts
563
+ var _promise, _resolveFn, _rejectFn;
564
+ var Future = class {
565
+ constructor() {
566
+ __privateAdd(this, _promise);
567
+ __privateAdd(this, _resolveFn, () => {
568
+ throw new Error("This Promise is not working as expected.");
569
+ });
570
+ __privateAdd(this, _rejectFn, () => {
571
+ throw new Error("This Promise is not working as expected.");
572
+ });
573
+ __privateSet(this, _promise, new Promise((resolve, reject) => {
574
+ __privateSet(this, _resolveFn, resolve);
575
+ __privateSet(this, _rejectFn, reject);
576
+ }));
577
+ }
578
+ async asPromise() {
579
+ return __privateGet(this, _promise);
580
+ }
581
+ resolve(value) {
582
+ __privateGet(this, _resolveFn).call(this, value);
583
+ }
584
+ reject(reason) {
585
+ __privateGet(this, _rejectFn).call(this, reason);
586
+ }
587
+ };
588
+ _promise = new WeakMap();
589
+ _resolveFn = new WeakMap();
590
+ _rejectFn = new WeakMap();
591
+ export {
592
+ Future,
593
+ IDMode,
594
+ Level,
595
+ LevelHandlerImpl,
596
+ LogCollector,
597
+ LogWriter,
598
+ LoggerImpl,
599
+ MockLogger,
600
+ None,
601
+ Option,
602
+ RandomMode,
603
+ Result,
604
+ ResultError,
605
+ ResultOK,
606
+ Some,
607
+ String2TimeMode,
608
+ Time,
609
+ TimeMode,
610
+ TimeUnits
611
+ };
26
612
  //# sourceMappingURL=index.js.map