@adviser/cement 0.2.28 → 0.2.30

Sign up to get free protection for your applications and to get access to all the features.
Files changed (318) hide show
  1. package/{base-sys-abstraction-C9WW3w57.d.cts → base-sys-abstraction-BkEiLHl0.d.ts} +8 -4
  2. package/{base-sys-abstraction-C9WW3w57.d.ts → base-sys-abstraction-Qj7pkY1N.d.cts} +8 -4
  3. package/{chunk-OXD3YZZ7.js → chunk-7KFVMTOS.js} +3 -47
  4. package/chunk-7KFVMTOS.js.map +1 -0
  5. package/{chunk-P5RXA4C4.js → chunk-GES3MUGV.js} +24 -27
  6. package/{chunk-LCPYQVWT.js.map → chunk-GES3MUGV.js.map} +1 -1
  7. package/{chunk-YDIUMYIE.js → chunk-Q65HLCNL.js} +8 -7
  8. package/chunk-Q65HLCNL.js.map +1 -0
  9. package/{chunk-DPIL5UIL.js → chunk-WMMUXBDX.js} +6 -2
  10. package/chunk-WMMUXBDX.js.map +1 -0
  11. package/{index-Dhb2fQiw.d.cts → index-Q3phXzYr.d.cts} +2 -21
  12. package/{index-CcsGcehs.d.ts → index-tIGZMHTc.d.ts} +2 -21
  13. package/index.cjs +288 -7345
  14. package/index.cjs.map +1 -1
  15. package/index.d.cts +74 -12
  16. package/index.d.ts +74 -12
  17. package/index.js +239 -7266
  18. package/index.js.map +1 -1
  19. package/node/index.cjs +220 -39
  20. package/node/index.cjs.map +1 -1
  21. package/node/index.d.cts +22 -4
  22. package/node/index.d.ts +22 -4
  23. package/node/index.js +201 -25
  24. package/node/index.js.map +1 -1
  25. package/package.json +34 -23
  26. package/src/LICENSE +201 -0
  27. package/src/README.md +39 -0
  28. package/src/base-sys-abstraction.ts +242 -0
  29. package/src/bin2text.ts +47 -0
  30. package/src/crypto.ts +125 -0
  31. package/src/file-service.ts +24 -0
  32. package/src/future.ts +27 -0
  33. package/src/index.ts +23 -0
  34. package/src/jsr.json +22 -0
  35. package/src/log-level-impl.ts +87 -0
  36. package/src/log-writer-impl.ts +58 -0
  37. package/src/logger-impl.ts +498 -0
  38. package/src/logger.ts +208 -0
  39. package/src/node/deno-file-service.ts +92 -0
  40. package/src/node/deno-sys-abstraction.ts +133 -0
  41. package/src/node/index.ts +4 -0
  42. package/src/node/mock-file-service.ts +45 -0
  43. package/src/node/node-file-service.ts +91 -0
  44. package/src/node/node-sys-abstraction.ts +121 -0
  45. package/src/option.ts +60 -0
  46. package/src/refcounted.ts +23 -0
  47. package/src/resolve-once.ts +179 -0
  48. package/src/result.ts +165 -0
  49. package/src/runtime.ts +36 -0
  50. package/src/sys-abstraction.ts +53 -0
  51. package/src/sys-env.ts +216 -0
  52. package/src/test/log-write-stream.ts +95 -0
  53. package/src/test/mock-logger.ts +40 -0
  54. package/src/time.ts +20 -0
  55. package/src/tracer.ts +222 -0
  56. package/src/txt-en-decoder.ts +21 -0
  57. package/src/uri.ts +421 -0
  58. package/src/utils/console-write-stream.ts +72 -0
  59. package/src/utils/fanout-write-stream.ts +32 -0
  60. package/src/utils/index.ts +6 -0
  61. package/src/utils/rebuffer.ts +75 -0
  62. package/src/utils/stream-map.ts +67 -0
  63. package/src/utils/stream2string.ts +47 -0
  64. package/src/utils/string2stream.ts +14 -0
  65. package/src/version.ts +3 -0
  66. package/src/web/index.ts +1 -0
  67. package/src/web/web-sys-abstraction.ts +80 -0
  68. package/ts/base-sys-abstraction.d.ts +84 -0
  69. package/ts/base-sys-abstraction.d.ts.map +1 -0
  70. package/ts/base-sys-abstraction.js +178 -0
  71. package/ts/base-sys-abstraction.js.map +1 -0
  72. package/ts/base-sys-abstraction.test.d.ts +2 -0
  73. package/ts/base-sys-abstraction.test.d.ts.map +1 -0
  74. package/ts/base-sys-abstraction.test.js +82 -0
  75. package/ts/base-sys-abstraction.test.js.map +1 -0
  76. package/ts/bin2text.d.ts +3 -0
  77. package/ts/bin2text.d.ts.map +1 -0
  78. package/ts/bin2text.js +43 -0
  79. package/ts/bin2text.js.map +1 -0
  80. package/ts/bin2text.test.d.ts +2 -0
  81. package/ts/bin2text.test.d.ts.map +1 -0
  82. package/ts/bin2text.test.js +51 -0
  83. package/ts/bin2text.test.js.map +1 -0
  84. package/ts/crypto.d.ts +76 -0
  85. package/ts/crypto.d.ts.map +1 -0
  86. package/ts/crypto.js +22 -0
  87. package/ts/crypto.js.map +1 -0
  88. package/ts/crypto.test.d.ts +2 -0
  89. package/ts/crypto.test.d.ts.map +1 -0
  90. package/ts/crypto.test.js +14 -0
  91. package/ts/crypto.test.js.map +1 -0
  92. package/ts/file-service.d.ts +17 -0
  93. package/ts/file-service.d.ts.map +1 -0
  94. package/ts/file-service.js +2 -0
  95. package/ts/file-service.js.map +1 -0
  96. package/ts/future.d.ts +8 -0
  97. package/ts/future.d.ts.map +1 -0
  98. package/ts/future.js +38 -0
  99. package/ts/future.js.map +1 -0
  100. package/ts/future.test.d.ts +2 -0
  101. package/ts/future.test.d.ts.map +1 -0
  102. package/ts/future.test.js +28 -0
  103. package/ts/future.test.js.map +1 -0
  104. package/ts/index.d.ts +24 -0
  105. package/ts/index.d.ts.map +1 -0
  106. package/ts/index.js +24 -0
  107. package/ts/index.js.map +1 -0
  108. package/ts/log-level-impl.d.ts +14 -0
  109. package/ts/log-level-impl.d.ts.map +1 -0
  110. package/ts/log-level-impl.js +72 -0
  111. package/ts/log-level-impl.js.map +1 -0
  112. package/ts/log-writer-impl.d.ts +10 -0
  113. package/ts/log-writer-impl.d.ts.map +1 -0
  114. package/ts/log-writer-impl.js +45 -0
  115. package/ts/log-writer-impl.js.map +1 -0
  116. package/ts/logger-impl.d.ts +71 -0
  117. package/ts/logger-impl.d.ts.map +1 -0
  118. package/ts/logger-impl.js +412 -0
  119. package/ts/logger-impl.js.map +1 -0
  120. package/ts/logger.d.ts +84 -0
  121. package/ts/logger.d.ts.map +1 -0
  122. package/ts/logger.js +114 -0
  123. package/ts/logger.js.map +1 -0
  124. package/ts/logger.test.d.ts +2 -0
  125. package/ts/logger.test.d.ts.map +1 -0
  126. package/ts/logger.test.js +1023 -0
  127. package/ts/logger.test.js.map +1 -0
  128. package/ts/node/deno-file-service.d.ts +17 -0
  129. package/ts/node/deno-file-service.d.ts.map +1 -0
  130. package/ts/node/deno-file-service.js +65 -0
  131. package/ts/node/deno-file-service.js.map +1 -0
  132. package/ts/node/deno-sys-abstraction.d.ts +22 -0
  133. package/ts/node/deno-sys-abstraction.d.ts.map +1 -0
  134. package/ts/node/deno-sys-abstraction.js +101 -0
  135. package/ts/node/deno-sys-abstraction.js.map +1 -0
  136. package/ts/node/index.d.ts +5 -0
  137. package/ts/node/index.d.ts.map +1 -0
  138. package/ts/node/index.js +5 -0
  139. package/ts/node/index.js.map +1 -0
  140. package/ts/node/mock-file-service.d.ts +11 -0
  141. package/ts/node/mock-file-service.d.ts.map +1 -0
  142. package/ts/node/mock-file-service.js +34 -0
  143. package/ts/node/mock-file-service.js.map +1 -0
  144. package/ts/node/mock-file-service.test.d.ts +2 -0
  145. package/ts/node/mock-file-service.test.d.ts.map +1 -0
  146. package/ts/node/mock-file-service.test.js +31 -0
  147. package/ts/node/mock-file-service.test.js.map +1 -0
  148. package/ts/node/node-file-service.d.ts +16 -0
  149. package/ts/node/node-file-service.d.ts.map +1 -0
  150. package/ts/node/node-file-service.js +71 -0
  151. package/ts/node/node-file-service.js.map +1 -0
  152. package/ts/node/node-sys-abstraction.d.ts +22 -0
  153. package/ts/node/node-sys-abstraction.d.ts.map +1 -0
  154. package/ts/node/node-sys-abstraction.js +99 -0
  155. package/ts/node/node-sys-abstraction.js.map +1 -0
  156. package/ts/node/node-sys-abstraction.test.d.ts +2 -0
  157. package/ts/node/node-sys-abstraction.test.d.ts.map +1 -0
  158. package/ts/node/node-sys-abstraction.test.js +83 -0
  159. package/ts/node/node-sys-abstraction.test.js.map +1 -0
  160. package/ts/option.d.ts +25 -0
  161. package/ts/option.d.ts.map +1 -0
  162. package/ts/option.js +47 -0
  163. package/ts/option.js.map +1 -0
  164. package/ts/refcounted.d.ts +2 -0
  165. package/ts/refcounted.d.ts.map +1 -0
  166. package/ts/refcounted.js +19 -0
  167. package/ts/refcounted.js.map +1 -0
  168. package/ts/refcounted.test.d.ts +2 -0
  169. package/ts/refcounted.test.d.ts.map +1 -0
  170. package/ts/refcounted.test.js +39 -0
  171. package/ts/refcounted.test.js.map +1 -0
  172. package/ts/resolve-once.d.ts +46 -0
  173. package/ts/resolve-once.d.ts.map +1 -0
  174. package/ts/resolve-once.js +152 -0
  175. package/ts/resolve-once.js.map +1 -0
  176. package/ts/resolve-once.test.d.ts +2 -0
  177. package/ts/resolve-once.test.d.ts.map +1 -0
  178. package/ts/resolve-once.test.js +283 -0
  179. package/ts/resolve-once.test.js.map +1 -0
  180. package/ts/result.d.ts +34 -0
  181. package/ts/result.d.ts.map +1 -0
  182. package/ts/result.js +85 -0
  183. package/ts/result.js.map +1 -0
  184. package/ts/result.test.d.ts +2 -0
  185. package/ts/result.test.d.ts.map +1 -0
  186. package/ts/result.test.js +79 -0
  187. package/ts/result.test.js.map +1 -0
  188. package/ts/runtime.d.ts +8 -0
  189. package/ts/runtime.d.ts.map +1 -0
  190. package/ts/runtime.js +26 -0
  191. package/ts/runtime.js.map +1 -0
  192. package/ts/sys-abstraction.d.ts +36 -0
  193. package/ts/sys-abstraction.d.ts.map +1 -0
  194. package/ts/sys-abstraction.js +31 -0
  195. package/ts/sys-abstraction.js.map +1 -0
  196. package/ts/sys-env.d.ts +48 -0
  197. package/ts/sys-env.d.ts.map +1 -0
  198. package/ts/sys-env.js +176 -0
  199. package/ts/sys-env.js.map +1 -0
  200. package/ts/sys-env.test.d.ts +2 -0
  201. package/ts/sys-env.test.d.ts.map +1 -0
  202. package/ts/sys-env.test.js +51 -0
  203. package/ts/sys-env.test.js.map +1 -0
  204. package/ts/test/log-write-stream.d.ts +27 -0
  205. package/ts/test/log-write-stream.d.ts.map +1 -0
  206. package/ts/test/log-write-stream.js +74 -0
  207. package/ts/test/log-write-stream.js.map +1 -0
  208. package/ts/test/mock-logger.d.ts +14 -0
  209. package/ts/test/mock-logger.d.ts.map +1 -0
  210. package/ts/test/mock-logger.js +29 -0
  211. package/ts/test/mock-logger.js.map +1 -0
  212. package/ts/test/mock-logger.test.d.ts +2 -0
  213. package/ts/test/mock-logger.test.d.ts.map +1 -0
  214. package/ts/test/mock-logger.test.js +63 -0
  215. package/ts/test/mock-logger.test.js.map +1 -0
  216. package/ts/test/test-exit-handler.d.ts +2 -0
  217. package/ts/test/test-exit-handler.d.ts.map +1 -0
  218. package/ts/test/test-exit-handler.js +57 -0
  219. package/ts/test/test-exit-handler.js.map +1 -0
  220. package/ts/time.d.ts +13 -0
  221. package/ts/time.d.ts.map +1 -0
  222. package/ts/time.js +14 -0
  223. package/ts/time.js.map +1 -0
  224. package/ts/tracer.d.ts +59 -0
  225. package/ts/tracer.d.ts.map +1 -0
  226. package/ts/tracer.js +148 -0
  227. package/ts/tracer.js.map +1 -0
  228. package/ts/tracer.test.d.ts +2 -0
  229. package/ts/tracer.test.d.ts.map +1 -0
  230. package/ts/tracer.test.js +311 -0
  231. package/ts/tracer.test.js.map +1 -0
  232. package/ts/txt-en-decoder.d.ts +10 -0
  233. package/ts/txt-en-decoder.d.ts.map +1 -0
  234. package/ts/txt-en-decoder.js +15 -0
  235. package/ts/txt-en-decoder.js.map +1 -0
  236. package/ts/uri.d.ts +67 -0
  237. package/ts/uri.d.ts.map +1 -0
  238. package/ts/uri.js +283 -0
  239. package/ts/uri.js.map +1 -0
  240. package/ts/uri.test.d.ts +2 -0
  241. package/ts/uri.test.d.ts.map +1 -0
  242. package/ts/uri.test.js +119 -0
  243. package/ts/uri.test.js.map +1 -0
  244. package/ts/utils/console-write-stream.d.ts +21 -0
  245. package/ts/utils/console-write-stream.d.ts.map +1 -0
  246. package/ts/utils/console-write-stream.js +62 -0
  247. package/ts/utils/console-write-stream.js.map +1 -0
  248. package/ts/utils/fanout-write-stream.d.ts +12 -0
  249. package/ts/utils/fanout-write-stream.d.ts.map +1 -0
  250. package/ts/utils/fanout-write-stream.js +24 -0
  251. package/ts/utils/fanout-write-stream.js.map +1 -0
  252. package/ts/utils/index.d.ts +7 -0
  253. package/ts/utils/index.d.ts.map +1 -0
  254. package/ts/utils/index.js +7 -0
  255. package/ts/utils/index.js.map +1 -0
  256. package/ts/utils/rebuffer.d.ts +3 -0
  257. package/ts/utils/rebuffer.d.ts.map +1 -0
  258. package/ts/utils/rebuffer.js +60 -0
  259. package/ts/utils/rebuffer.js.map +1 -0
  260. package/ts/utils/rebuffer.test.d.ts +2 -0
  261. package/ts/utils/rebuffer.test.d.ts.map +1 -0
  262. package/ts/utils/rebuffer.test.js +77 -0
  263. package/ts/utils/rebuffer.test.js.map +1 -0
  264. package/ts/utils/stream-map.d.ts +9 -0
  265. package/ts/utils/stream-map.d.ts.map +1 -0
  266. package/ts/utils/stream-map.js +62 -0
  267. package/ts/utils/stream-map.js.map +1 -0
  268. package/ts/utils/stream-map.test.d.ts +2 -0
  269. package/ts/utils/stream-map.test.d.ts.map +1 -0
  270. package/ts/utils/stream-map.test.js +87 -0
  271. package/ts/utils/stream-map.test.js.map +1 -0
  272. package/ts/utils/stream-test-helper.d.ts +17 -0
  273. package/ts/utils/stream-test-helper.d.ts.map +1 -0
  274. package/ts/utils/stream-test-helper.js +37 -0
  275. package/ts/utils/stream-test-helper.js.map +1 -0
  276. package/ts/utils/stream2string.d.ts +3 -0
  277. package/ts/utils/stream2string.d.ts.map +1 -0
  278. package/ts/utils/stream2string.js +48 -0
  279. package/ts/utils/stream2string.js.map +1 -0
  280. package/ts/utils/stream2string.test.d.ts +2 -0
  281. package/ts/utils/stream2string.test.d.ts.map +1 -0
  282. package/ts/utils/stream2string.test.js +29 -0
  283. package/ts/utils/stream2string.test.js.map +1 -0
  284. package/ts/utils/string2stream.d.ts +4 -0
  285. package/ts/utils/string2stream.d.ts.map +1 -0
  286. package/ts/utils/string2stream.js +13 -0
  287. package/ts/utils/string2stream.js.map +1 -0
  288. package/ts/utils/string2stream.test.d.ts +2 -0
  289. package/ts/utils/string2stream.test.d.ts.map +1 -0
  290. package/ts/utils/string2stream.test.js +6 -0
  291. package/ts/utils/string2stream.test.js.map +1 -0
  292. package/ts/version.d.ts +2 -0
  293. package/ts/version.d.ts.map +1 -0
  294. package/ts/version.js +4 -0
  295. package/ts/version.js.map +1 -0
  296. package/ts/web/index.d.ts +2 -0
  297. package/ts/web/index.d.ts.map +1 -0
  298. package/ts/web/index.js +2 -0
  299. package/ts/web/index.js.map +1 -0
  300. package/ts/web/web-sys-abstraction.d.ts +4 -0
  301. package/ts/web/web-sys-abstraction.d.ts.map +1 -0
  302. package/ts/web/web-sys-abstraction.js +64 -0
  303. package/ts/web/web-sys-abstraction.js.map +1 -0
  304. package/utils/index.cjs +0 -42
  305. package/utils/index.cjs.map +1 -1
  306. package/utils/index.d.cts +1 -2
  307. package/utils/index.d.ts +1 -2
  308. package/utils/index.js +2 -7
  309. package/web/index.cjs +25 -7
  310. package/web/index.cjs.map +1 -1
  311. package/web/index.d.cts +2 -1
  312. package/web/index.d.ts +2 -1
  313. package/web/index.js +3 -3
  314. package/chunk-DPIL5UIL.js.map +0 -1
  315. package/chunk-LCPYQVWT.js +0 -21
  316. package/chunk-OXD3YZZ7.js.map +0 -1
  317. package/chunk-P5RXA4C4.js.map +0 -1
  318. package/chunk-YDIUMYIE.js.map +0 -1
@@ -0,0 +1,47 @@
1
+ export async function stream2string(stream?: ReadableStream<Uint8Array> | null, maxSize?: number): Promise<string> {
2
+ if (!stream) {
3
+ return Promise.resolve("");
4
+ }
5
+ const reader = stream.getReader();
6
+ let res = "";
7
+ const decoder = new TextDecoder();
8
+ let rSize = 0;
9
+ while (typeof maxSize === "undefined" || rSize < maxSize) {
10
+ try {
11
+ const read = await reader.read();
12
+ if (read.done) {
13
+ break;
14
+ }
15
+ if (maxSize && rSize + read.value.length > maxSize) {
16
+ read.value = read.value.slice(0, maxSize - rSize);
17
+ }
18
+ const block = decoder.decode(read.value, { stream: true });
19
+ rSize += read.value.length;
20
+ res += block;
21
+ } catch (err) {
22
+ return Promise.reject(err);
23
+ }
24
+ }
25
+ return Promise.resolve(res);
26
+ }
27
+
28
+ export async function stream2uint8array(stream?: ReadableStream<Uint8Array> | null): Promise<Uint8Array> {
29
+ if (!stream) {
30
+ return Promise.resolve(new Uint8Array());
31
+ }
32
+ const reader = stream.getReader();
33
+ let res = new Uint8Array();
34
+ // eslint-disable-next-line no-constant-condition
35
+ while (1) {
36
+ try {
37
+ const { done, value } = await reader.read();
38
+ if (done) {
39
+ break;
40
+ }
41
+ res = new Uint8Array([...res, ...value]);
42
+ } catch (err) {
43
+ return Promise.reject(err);
44
+ }
45
+ }
46
+ return Promise.resolve(res);
47
+ }
@@ -0,0 +1,14 @@
1
+ import { TxtEnDecoder, Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
2
+
3
+ export function string2stream(str: string, ende: TxtEnDecoder = Utf8EnDecoderSingleton()): ReadableStream<Uint8Array> {
4
+ return uint8array2stream(ende.encode(str));
5
+ }
6
+
7
+ export function uint8array2stream(str: Uint8Array): ReadableStream<Uint8Array> {
8
+ return new ReadableStream<Uint8Array>({
9
+ start(controller): void {
10
+ controller.enqueue(str);
11
+ controller.close();
12
+ },
13
+ });
14
+ }
package/src/version.ts ADDED
@@ -0,0 +1,3 @@
1
+ export const VERSION = Object.keys({
2
+ __packageVersion__: "xxxx",
3
+ })[0] as string;
@@ -0,0 +1 @@
1
+ export * from "./web-sys-abstraction.js";
@@ -0,0 +1,80 @@
1
+ import { BaseSysAbstraction, WrapperSysAbstraction, WrapperSysAbstractionParams } from "../base-sys-abstraction.js";
2
+ import { FileService, NamedWritableStream } from "../file-service.js";
3
+ import { SysAbstraction, SystemService, VoidFunc } from "../sys-abstraction.js";
4
+ import { Env, envFactory } from "../sys-env.js";
5
+ import { Utf8EnDecoderSingleton } from "../txt-en-decoder.js";
6
+
7
+ class WebFileService implements FileService {
8
+ get baseDir(): string {
9
+ throw new Error("basedir-Method not implemented.");
10
+ }
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ create(fname: string): Promise<NamedWritableStream> {
13
+ throw new Error("create-Method not implemented.");
14
+ }
15
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
+ readFileString(fname: string): Promise<string> {
17
+ throw new Error("readFileString-Method not implemented.");
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
+ writeFileString(fname: string, content: string): Promise<void> {
21
+ throw new Error("writeFileString-Method not implemented.");
22
+ }
23
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
+ abs(fname: string): string {
25
+ throw new Error("abs-Method not implemented.");
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ join(...paths: string[]): string {
29
+ throw new Error("join-Method not implemented.");
30
+ }
31
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
+ relative(from: string, to?: string | undefined): string {
33
+ throw new Error("relative-Method not implemented.");
34
+ }
35
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
+ dirname(fname: string): string {
37
+ throw new Error("dirname-Method not implemented.");
38
+ }
39
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
40
+ basename(fname: string): string {
41
+ throw new Error("basename-Method not implemented.");
42
+ }
43
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
44
+ nodeImport(fname: string): string {
45
+ throw new Error("nodeImport-Method not implemented.");
46
+ }
47
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
48
+ isAbsolute(fname: string): boolean {
49
+ throw new Error("isAbsolute-Method not implemented.");
50
+ }
51
+ }
52
+
53
+ class WebSystemService implements SystemService {
54
+ Env(): Env {
55
+ return envFactory();
56
+ }
57
+ Args(): string[] {
58
+ throw new Error("Args-Method not implemented.");
59
+ }
60
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
61
+ OnExit(hdl: VoidFunc): VoidFunc {
62
+ throw new Error("OnExit-Method not implemented.");
63
+ }
64
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
65
+ Exit(code: number): void {
66
+ throw new Error("Exit-Method not implemented.");
67
+ }
68
+ }
69
+
70
+ let my: BaseSysAbstraction | undefined = undefined;
71
+ export function WebSysAbstraction(param?: WrapperSysAbstractionParams): SysAbstraction {
72
+ if (!my) {
73
+ my = new BaseSysAbstraction({
74
+ TxtEnDecoder: param?.TxtEnDecoder || Utf8EnDecoderSingleton(),
75
+ FileSystem: new WebFileService(),
76
+ SystemService: new WebSystemService(),
77
+ });
78
+ }
79
+ return new WrapperSysAbstraction(my, param);
80
+ }
@@ -0,0 +1,84 @@
1
+ import { FileService } from "./file-service.js";
2
+ import { TimeMode, RandomMode, IDMode, SystemService, VoidFunc, SysAbstraction } from "./sys-abstraction.js";
3
+ import { Time } from "./time.js";
4
+ import { TxtEnDecoder } from "./txt-en-decoder.js";
5
+ export declare class SysTime extends Time {
6
+ Now(): Date;
7
+ Sleep(duration: number): Promise<void>;
8
+ }
9
+ export declare class ConstTime extends Time {
10
+ Now(): Date;
11
+ Sleep(duration: number): Promise<void>;
12
+ }
13
+ export declare class StepTime extends Time {
14
+ _step: Date;
15
+ readonly _start: Date;
16
+ constructor();
17
+ Now(steps?: number): Date;
18
+ Sleep(duration: number): Promise<void>;
19
+ }
20
+ export declare function TimeFactory(timeMode: TimeMode): Time;
21
+ export declare class RandomService {
22
+ readonly _mode: RandomMode;
23
+ _step: number;
24
+ constructor(mode: RandomMode);
25
+ Random0ToValue(value: number): number;
26
+ }
27
+ export declare class IdService {
28
+ readonly _mode: IDMode;
29
+ _step: number;
30
+ constructor(mode?: IDMode);
31
+ NextId(): string;
32
+ }
33
+ export interface BaseSysAbstractionParams {
34
+ readonly TxtEnDecoder: TxtEnDecoder;
35
+ readonly FileSystem: FileService;
36
+ readonly SystemService: SystemService;
37
+ }
38
+ export interface ExitHandler {
39
+ readonly hdl: VoidFunc;
40
+ readonly id: string;
41
+ }
42
+ export interface ExitService {
43
+ injectExitHandlers(hdls: ExitHandler[]): void;
44
+ exit(code: number): void;
45
+ }
46
+ export declare class BaseSysAbstraction {
47
+ readonly _time: SysTime;
48
+ readonly _stdout: WritableStream;
49
+ readonly _stderr: WritableStream;
50
+ readonly _idService: IdService;
51
+ readonly _randomService: RandomService;
52
+ readonly _fileSystem: FileService;
53
+ readonly _systemService: SystemService;
54
+ readonly _txtEnDe: TxtEnDecoder;
55
+ constructor(params: BaseSysAbstractionParams);
56
+ }
57
+ export interface WrapperSysAbstractionParams {
58
+ readonly TimeMode?: TimeMode;
59
+ readonly IdMode?: IDMode;
60
+ readonly Stdout?: WritableStream<Uint8Array>;
61
+ readonly Stderr?: WritableStream<Uint8Array>;
62
+ readonly RandomMode?: RandomMode;
63
+ readonly FileSystem?: FileService;
64
+ readonly SystemService?: SystemService;
65
+ readonly TxtEnDecoder?: TxtEnDecoder;
66
+ }
67
+ export declare class WrapperSysAbstraction implements SysAbstraction {
68
+ readonly _time: Time;
69
+ readonly _stdout: WritableStream<Uint8Array>;
70
+ readonly _stderr: WritableStream<Uint8Array>;
71
+ readonly _idService: IdService;
72
+ readonly _randomService: RandomService;
73
+ readonly _fileSystem: FileService;
74
+ readonly _systemService: SystemService;
75
+ constructor(base: BaseSysAbstraction, params?: WrapperSysAbstractionParams);
76
+ Time(): Time;
77
+ NextId(): string;
78
+ Random0ToValue(value: number): number;
79
+ Stdout(): WritableStream;
80
+ Stderr(): WritableStream;
81
+ System(): SystemService;
82
+ FileSystem(): FileService;
83
+ }
84
+ //# sourceMappingURL=base-sys-abstraction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-sys-abstraction.d.ts","sourceRoot":"","sources":["../../src/base-sys-abstraction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,qBAAa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AAW,EAAE,WAAW,CAAC;IAClC,QAAQ,CAAC,cAAc,EAAE,aAAa,CAAC;gBAC3B,IAAI,EAAE,kBAAkB,EAAE,MAAM,CAAC,EAAE,2BAA2B;IAgC1E,IAAI,IAAI,IAAI;IAGZ,MAAM,IAAI,MAAM;IAGhB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAGrC,MAAM,IAAI,cAAc;IAGxB,MAAM,IAAI,cAAc;IAIxB,MAAM,IAAI,aAAa;IAGvB,UAAU,IAAI,WAAW;CAG1B"}
@@ -0,0 +1,178 @@
1
+ import { TimeMode, RandomMode, IDMode } from "./sys-abstraction.js";
2
+ import { Time } from "./time.js";
3
+ export class SysTime extends Time {
4
+ Now() {
5
+ return new Date();
6
+ }
7
+ Sleep(duration) {
8
+ return new Promise((resolve) => {
9
+ setTimeout(() => {
10
+ resolve();
11
+ }, duration);
12
+ });
13
+ }
14
+ }
15
+ export class ConstTime extends Time {
16
+ Now() {
17
+ return new Date(2021, 1, 1, 0, 0, 0, 0);
18
+ }
19
+ Sleep(duration) {
20
+ return Promise.resolve();
21
+ }
22
+ }
23
+ export class StepTime extends Time {
24
+ constructor() {
25
+ super();
26
+ this._step = new ConstTime().Now();
27
+ this._start = this._step;
28
+ }
29
+ Now(steps = 1) {
30
+ for (let i = 0; steps > 0 && i < steps; i++) {
31
+ this._step = new Date(this._step.getTime() + 1000);
32
+ }
33
+ if (steps < 1) {
34
+ this._step = new Date(this._start.getTime() + steps * -1000);
35
+ }
36
+ return this._step;
37
+ }
38
+ Sleep(duration) {
39
+ this._step = new Date(this._step.getTime() + duration);
40
+ return Promise.resolve();
41
+ }
42
+ }
43
+ export function TimeFactory(timeMode) {
44
+ switch (timeMode) {
45
+ case TimeMode.REAL:
46
+ return new SysTime();
47
+ case TimeMode.CONST:
48
+ return new ConstTime();
49
+ case TimeMode.STEP:
50
+ return new StepTime();
51
+ }
52
+ return new SysTime();
53
+ }
54
+ export class RandomService {
55
+ constructor(mode) {
56
+ this._step = 0;
57
+ this._mode = mode;
58
+ }
59
+ Random0ToValue(value) {
60
+ switch (this._mode) {
61
+ case RandomMode.CONST:
62
+ return 0.5 * value;
63
+ case RandomMode.STEP:
64
+ this._step += 0.0001;
65
+ return this._step * value;
66
+ case RandomMode.RANDOM:
67
+ return Math.random() * value;
68
+ default:
69
+ throw new Error("Unknown RandomMode");
70
+ }
71
+ }
72
+ }
73
+ export class IdService {
74
+ constructor(mode) {
75
+ this._step = 0;
76
+ if (!mode) {
77
+ mode = IDMode.UUID;
78
+ }
79
+ this._mode = mode;
80
+ }
81
+ NextId() {
82
+ switch (this._mode) {
83
+ case IDMode.UUID:
84
+ return crypto.randomUUID();
85
+ case IDMode.CONST:
86
+ return "VeryUniqueID";
87
+ case IDMode.STEP:
88
+ return `STEPId-${this._step++}`;
89
+ default:
90
+ throw new Error("Unknown IDMode");
91
+ }
92
+ }
93
+ }
94
+ export class BaseSysAbstraction {
95
+ constructor(params) {
96
+ this._time = new SysTime();
97
+ this._idService = new IdService();
98
+ this._randomService = new RandomService(RandomMode.RANDOM);
99
+ this._fileSystem = params.FileSystem;
100
+ this._systemService = params.SystemService;
101
+ this._txtEnDe = params.TxtEnDecoder;
102
+ const decoder = this._txtEnDe;
103
+ this._stdout = new WritableStream({
104
+ write(chunk) {
105
+ return new Promise((resolve) => {
106
+ const decoded = decoder.decode(chunk);
107
+ console.log(decoded.trimEnd());
108
+ resolve();
109
+ });
110
+ },
111
+ });
112
+ this._stderr = new WritableStream({
113
+ write(chunk) {
114
+ return new Promise((resolve) => {
115
+ const decoded = decoder.decode(chunk);
116
+ console.error(decoded.trimEnd());
117
+ resolve();
118
+ });
119
+ },
120
+ });
121
+ }
122
+ }
123
+ export class WrapperSysAbstraction {
124
+ constructor(base, params) {
125
+ this._time = base._time;
126
+ this._stdout = base._stdout;
127
+ this._stderr = base._stderr;
128
+ this._idService = base._idService;
129
+ this._randomService = base._randomService;
130
+ this._fileSystem = base._fileSystem;
131
+ this._systemService = base._systemService;
132
+ if (params) {
133
+ if (params.TimeMode) {
134
+ this._time = TimeFactory(params.TimeMode);
135
+ }
136
+ if (params.Stdout) {
137
+ this._stdout = params.Stdout;
138
+ }
139
+ if (params.Stderr) {
140
+ this._stderr = params.Stderr;
141
+ }
142
+ if (params.IdMode) {
143
+ this._idService = new IdService(params.IdMode);
144
+ }
145
+ if (params.RandomMode) {
146
+ this._randomService = new RandomService(params.RandomMode);
147
+ }
148
+ if (params.FileSystem) {
149
+ this._fileSystem = params.FileSystem;
150
+ }
151
+ if (params.SystemService) {
152
+ this._systemService = params.SystemService;
153
+ }
154
+ }
155
+ }
156
+ Time() {
157
+ return this._time;
158
+ }
159
+ NextId() {
160
+ return this._idService.NextId();
161
+ }
162
+ Random0ToValue(value) {
163
+ return this._randomService.Random0ToValue(value);
164
+ }
165
+ Stdout() {
166
+ return this._stdout;
167
+ }
168
+ Stderr() {
169
+ return this._stderr;
170
+ }
171
+ System() {
172
+ return this._systemService;
173
+ }
174
+ FileSystem() {
175
+ return this._fileSystem;
176
+ }
177
+ }
178
+ //# sourceMappingURL=base-sys-abstraction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"base-sys-abstraction.js","sourceRoot":"","sources":["../../src/base-sys-abstraction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,EAA2C,MAAM,sBAAsB,CAAC;AAC7G,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,MAAM,OAAO,OAAQ,SAAQ,IAAI;IAC/B,GAAG;QACD,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,KAAK,CAAC,QAAgB;QACpB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,EAAE,CAAC;YACZ,CAAC,EAAE,QAAQ,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAED,MA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IAAI,MAAM,CAAC,aAAa,EAAE,CAAC;gBACzB,IAAI,CAAC,cAAc,GAAG,MAAM,CAAC,aAAa,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI;QACF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;IAClC,CAAC;IACD,cAAc,CAAC,KAAa;QAC1B,OAAO,IAAI,CAAC,cAAc,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC;IACnD,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IACD,MAAM;QACJ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IACD,UAAU;QACR,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=base-sys-abstraction.test.d.ts.map
@@ -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,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,IAAI,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC;IAC1B,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,IAAI,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC;IACvB,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,oBAAoB,EAAE,EAAE,EAAE,kBAAkB,EAAE,CAAC,CAAC;AAC5E,CAAC;AAED,IAAI,SAAS,EAAE,CAAC,SAAS,EAAE,CAAC;IAC1B,YAAY,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,mBAAmB,EAAE,EAAE,EAAE,iBAAiB,EAAE,CAAC,CAAC;AAC1E,CAAC;AAED,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;IACvC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,GAAG,EAAE;QA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AC,CAAC;YAC/B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC7B,MAAM,GAAG,GAAG,GAAG,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;gBACnC,MAAM,CAAC,GAAG,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,CAAC;gBACtC,MAAM,CAAC,GAAG,CAAC,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAC;YACtC,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size?: number): void;
2
+ export declare function bin2string(hex: ArrayBufferView, size?: number): string;
3
+ //# sourceMappingURL=bin2text.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.d.ts","sourceRoot":"","sources":["../../src/bin2text.ts"],"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
+ }
43
+ //# sourceMappingURL=bin2text.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.js","sourceRoot":"","sources":["../../src/bin2text.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,QAAQ,CAAC,GAAoB,EAAE,MAA8B,EAAE,IAAI,GAAG,CAAC;IACrF,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;IACvE,IAAI,MAAM,GAAG,IAAI,CAAC;IAClB,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC;QACd,IAAI,GAAG,GAAG,CAAC,MAAM,CAAC;IACpB,CAAC;IACD,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,IAAI,EAAE,IAAI,IAAI,IAAI,EAAE,CAAC;QAC7C,IAAI,IAAI,GAAG,IAAI,IAAI,IAAI,IAAI,GAAG,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;QAEhD,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,MAA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IACvD,MAAM,SAAS,GAAa,EAAE,CAAC;IAC/B,QAAQ,CACN,GAAG,EACH,CAAC,IAAI,EAAE,EAAE;QACP,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACvB,CAAC,EACD,IAAI,CACL,CAAC;IACF,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=bin2text.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bin2text.test.d.ts","sourceRoot":"","sources":["../../src/bin2text.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,51 @@
1
+ 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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