@adviser/cement 0.4.62 → 0.4.64-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/app-context.cjs.map +1 -1
- package/cjs/app-context.d.ts.map +1 -1
- package/cjs/base-sys-abstraction.cjs.map +1 -1
- package/cjs/base-sys-abstraction.d.ts.map +1 -1
- package/cjs/bin2text.cjs.map +1 -1
- package/cjs/bin2text.d.ts.map +1 -1
- package/cjs/coerce-binary.cjs.map +1 -1
- package/cjs/coerce-binary.d.ts.map +1 -1
- package/cjs/crypto.cjs.map +1 -1
- package/cjs/crypto.d.ts.map +1 -1
- package/cjs/future.cjs.map +1 -1
- package/cjs/future.d.ts.map +1 -1
- package/cjs/http_header.cjs.map +1 -1
- package/cjs/http_header.d.ts.map +1 -1
- package/cjs/index.cjs +1 -0
- package/cjs/index.cjs.map +1 -1
- package/cjs/index.d.ts +1 -0
- package/cjs/index.d.ts.map +1 -1
- package/cjs/is-json.cjs.map +1 -1
- package/cjs/is-json.d.ts.map +1 -1
- package/cjs/is-promise.cjs.map +1 -1
- package/cjs/is-promise.d.ts.map +1 -1
- package/cjs/keyed-ng.cjs +93 -0
- package/cjs/keyed-ng.cjs.map +1 -0
- package/cjs/keyed-ng.d.ts +51 -0
- package/cjs/keyed-ng.d.ts.map +1 -0
- package/cjs/keyed-ng.test.cjs +151 -0
- package/cjs/keyed-ng.test.cjs.map +1 -0
- package/cjs/keyed-ng.test.d.ts +2 -0
- package/cjs/keyed-ng.test.d.ts.map +1 -0
- package/cjs/lru-map-set.cjs +2 -1
- package/cjs/lru-map-set.cjs.map +1 -1
- package/cjs/lru-map-set.d.ts +4 -1
- package/cjs/lru-map-set.d.ts.map +1 -1
- package/cjs/on-func.cjs.map +1 -1
- package/cjs/on-func.d.ts.map +1 -1
- package/cjs/option.cjs.map +1 -1
- package/cjs/option.d.ts.map +1 -1
- package/cjs/poller.cjs +8 -3
- package/cjs/poller.cjs.map +1 -1
- package/cjs/poller.d.ts +9 -2
- package/cjs/poller.d.ts.map +1 -1
- package/cjs/promise-sleep.cjs.map +1 -1
- package/cjs/promise-sleep.d.ts.map +1 -1
- package/cjs/resolve-once.cjs +84 -43
- package/cjs/resolve-once.cjs.map +1 -1
- package/cjs/resolve-once.d.ts +31 -34
- package/cjs/resolve-once.d.ts.map +1 -1
- package/cjs/resolve-once.test.cjs +119 -31
- package/cjs/resolve-once.test.cjs.map +1 -1
- package/cjs/result.cjs.map +1 -1
- package/cjs/result.d.ts.map +1 -1
- package/cjs/runtime.cjs.map +1 -1
- package/cjs/runtime.d.ts.map +1 -1
- package/cjs/sys-env.cjs.map +1 -1
- package/cjs/sys-env.d.ts.map +1 -1
- package/cjs/timeouted.cjs.map +1 -1
- package/cjs/timeouted.d.ts.map +1 -1
- package/cjs/tracer.cjs.map +1 -1
- package/cjs/tracer.d.ts.map +1 -1
- package/cjs/txt-en-decoder.cjs +2 -5
- package/cjs/txt-en-decoder.cjs.map +1 -1
- package/cjs/txt-en-decoder.d.ts +1 -1
- package/cjs/txt-en-decoder.d.ts.map +1 -1
- package/cjs/uri.cjs.map +1 -1
- package/cjs/uri.d.ts.map +1 -1
- package/cjs/utils/coerce-uint8.cjs.map +1 -1
- package/cjs/utils/coerce-uint8.d.ts.map +1 -1
- package/cjs/utils/console-write-stream.cjs.map +1 -1
- package/cjs/utils/console-write-stream.d.ts.map +1 -1
- package/cjs/utils/consume.cjs.map +1 -1
- package/cjs/utils/consume.d.ts.map +1 -1
- package/cjs/utils/fanout-write-stream.cjs.map +1 -1
- package/cjs/utils/fanout-write-stream.d.ts.map +1 -1
- package/cjs/utils/get-params-result.cjs.map +1 -1
- package/cjs/utils/get-params-result.d.ts.map +1 -1
- package/cjs/utils/rebuffer.cjs.map +1 -1
- package/cjs/utils/rebuffer.d.ts.map +1 -1
- package/cjs/utils/relative-path.cjs.map +1 -1
- package/cjs/utils/relative-path.d.ts.map +1 -1
- package/cjs/utils/sorted-object.cjs.map +1 -1
- package/cjs/utils/sorted-object.d.ts.map +1 -1
- package/cjs/utils/stream-map.cjs.map +1 -1
- package/cjs/utils/stream-map.d.ts.map +1 -1
- package/cjs/utils/stream2string.cjs.map +1 -1
- package/cjs/utils/stream2string.d.ts.map +1 -1
- package/cjs/utils/string2stream.cjs.map +1 -1
- package/cjs/utils/string2stream.d.ts.map +1 -1
- package/cjs/utils/stripper.cjs.map +1 -1
- package/cjs/utils/stripper.d.ts.map +1 -1
- package/cjs/utils/to-sorted.cjs.map +1 -1
- package/cjs/utils/to-sorted.d.ts.map +1 -1
- package/cjs/utils/uint8array-equal.cjs.map +1 -1
- package/cjs/utils/uint8array-equal.d.ts.map +1 -1
- package/cjs/version.cjs +1 -1
- package/cjs/version.cjs.map +1 -1
- package/cjs/version.d.ts.map +1 -1
- package/deno.json +1 -1
- package/esm/app-context.d.ts.map +1 -1
- package/esm/app-context.js.map +1 -1
- package/esm/base-sys-abstraction.d.ts.map +1 -1
- package/esm/base-sys-abstraction.js.map +1 -1
- package/esm/bin2text.d.ts.map +1 -1
- package/esm/bin2text.js.map +1 -1
- package/esm/coerce-binary.d.ts.map +1 -1
- package/esm/coerce-binary.js.map +1 -1
- package/esm/crypto.d.ts.map +1 -1
- package/esm/crypto.js.map +1 -1
- package/esm/future.d.ts.map +1 -1
- package/esm/future.js.map +1 -1
- package/esm/http_header.d.ts.map +1 -1
- package/esm/http_header.js.map +1 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -0
- package/esm/index.js.map +1 -1
- package/esm/is-json.d.ts.map +1 -1
- package/esm/is-json.js.map +1 -1
- package/esm/is-promise.d.ts.map +1 -1
- package/esm/is-promise.js.map +1 -1
- package/esm/keyed-ng.d.ts +51 -0
- package/esm/keyed-ng.d.ts.map +1 -0
- package/esm/keyed-ng.js +89 -0
- package/esm/keyed-ng.js.map +1 -0
- package/esm/keyed-ng.test.d.ts +2 -0
- package/esm/keyed-ng.test.d.ts.map +1 -0
- package/esm/keyed-ng.test.js +149 -0
- package/esm/keyed-ng.test.js.map +1 -0
- package/esm/lru-map-set.d.ts +4 -1
- package/esm/lru-map-set.d.ts.map +1 -1
- package/esm/lru-map-set.js +2 -1
- package/esm/lru-map-set.js.map +1 -1
- package/esm/on-func.d.ts.map +1 -1
- package/esm/on-func.js.map +1 -1
- package/esm/option.d.ts.map +1 -1
- package/esm/option.js.map +1 -1
- package/esm/poller.d.ts +9 -2
- package/esm/poller.d.ts.map +1 -1
- package/esm/poller.js +8 -3
- package/esm/poller.js.map +1 -1
- package/esm/promise-sleep.d.ts.map +1 -1
- package/esm/promise-sleep.js.map +1 -1
- package/esm/resolve-once.d.ts +31 -34
- package/esm/resolve-once.d.ts.map +1 -1
- package/esm/resolve-once.js +83 -41
- package/esm/resolve-once.js.map +1 -1
- package/esm/resolve-once.test.js +119 -31
- package/esm/resolve-once.test.js.map +1 -1
- package/esm/result.d.ts.map +1 -1
- package/esm/result.js.map +1 -1
- package/esm/runtime.d.ts.map +1 -1
- package/esm/runtime.js.map +1 -1
- package/esm/sys-env.d.ts.map +1 -1
- package/esm/sys-env.js.map +1 -1
- package/esm/timeouted.d.ts.map +1 -1
- package/esm/timeouted.js.map +1 -1
- package/esm/tracer.d.ts.map +1 -1
- package/esm/tracer.js.map +1 -1
- package/esm/txt-en-decoder.d.ts +1 -1
- package/esm/txt-en-decoder.d.ts.map +1 -1
- package/esm/txt-en-decoder.js +2 -5
- package/esm/txt-en-decoder.js.map +1 -1
- package/esm/uri.d.ts.map +1 -1
- package/esm/uri.js.map +1 -1
- package/esm/utils/coerce-uint8.d.ts.map +1 -1
- package/esm/utils/coerce-uint8.js.map +1 -1
- package/esm/utils/console-write-stream.d.ts.map +1 -1
- package/esm/utils/console-write-stream.js.map +1 -1
- package/esm/utils/consume.d.ts.map +1 -1
- package/esm/utils/consume.js.map +1 -1
- package/esm/utils/fanout-write-stream.d.ts.map +1 -1
- package/esm/utils/fanout-write-stream.js.map +1 -1
- package/esm/utils/get-params-result.d.ts.map +1 -1
- package/esm/utils/get-params-result.js.map +1 -1
- package/esm/utils/rebuffer.d.ts.map +1 -1
- package/esm/utils/rebuffer.js.map +1 -1
- package/esm/utils/relative-path.d.ts.map +1 -1
- package/esm/utils/relative-path.js.map +1 -1
- package/esm/utils/sorted-object.d.ts.map +1 -1
- package/esm/utils/sorted-object.js.map +1 -1
- package/esm/utils/stream-map.d.ts.map +1 -1
- package/esm/utils/stream-map.js.map +1 -1
- package/esm/utils/stream2string.d.ts.map +1 -1
- package/esm/utils/stream2string.js.map +1 -1
- package/esm/utils/string2stream.d.ts.map +1 -1
- package/esm/utils/string2stream.js.map +1 -1
- package/esm/utils/stripper.d.ts.map +1 -1
- package/esm/utils/stripper.js.map +1 -1
- package/esm/utils/to-sorted.d.ts.map +1 -1
- package/esm/utils/to-sorted.js.map +1 -1
- package/esm/utils/uint8array-equal.d.ts.map +1 -1
- package/esm/utils/uint8array-equal.js.map +1 -1
- package/esm/version.d.ts.map +1 -1
- package/esm/version.js +1 -1
- package/esm/version.js.map +1 -1
- package/package.json +7 -4
- package/src/app-context.ts +111 -5
- package/src/base-sys-abstraction.ts +244 -0
- package/src/bin2text.ts +37 -0
- package/src/coerce-binary.ts +41 -0
- package/src/crypto.ts +35 -0
- package/src/future.ts +45 -1
- package/src/http_header.ts +277 -1
- package/src/index.ts +1 -0
- package/src/is-json.ts +21 -0
- package/src/is-promise.ts +26 -0
- package/src/keyed-ng.ts +628 -0
- package/src/lru-map-set.ts +52 -2
- package/src/on-func.ts +38 -0
- package/src/option.ts +27 -0
- package/src/poller.ts +65 -17
- package/src/promise-sleep.ts +32 -4
- package/src/resolve-once.ts +596 -93
- package/src/result.ts +50 -0
- package/src/runtime.ts +75 -2
- package/src/sys-env.ts +57 -0
- package/src/timeouted.ts +92 -0
- package/src/tracer.ts +41 -0
- package/src/txt-en-decoder.ts +2 -5
- package/src/uri.ts +76 -4
- package/src/utils/coerce-uint8.ts +60 -0
- package/src/utils/console-write-stream.ts +34 -0
- package/src/utils/consume.ts +106 -0
- package/src/utils/fanout-write-stream.ts +45 -0
- package/src/utils/get-params-result.ts +37 -0
- package/src/utils/rebuffer.ts +42 -0
- package/src/utils/relative-path.ts +108 -0
- package/src/utils/sorted-object.ts +50 -0
- package/src/utils/stream-map.ts +90 -0
- package/src/utils/stream2string.ts +35 -0
- package/src/utils/string2stream.ts +30 -0
- package/src/utils/stripper.ts +34 -0
- package/src/utils/to-sorted.ts +34 -0
- package/src/utils/uint8array-equal.ts +20 -0
- package/ts/cjs/app-context.d.ts.map +1 -1
- package/ts/cjs/app-context.js.map +1 -1
- package/ts/cjs/base-sys-abstraction.d.ts.map +1 -1
- package/ts/cjs/base-sys-abstraction.js.map +1 -1
- package/ts/cjs/bin2text.d.ts.map +1 -1
- package/ts/cjs/bin2text.js.map +1 -1
- package/ts/cjs/coerce-binary.d.ts.map +1 -1
- package/ts/cjs/coerce-binary.js.map +1 -1
- package/ts/cjs/crypto.d.ts.map +1 -1
- package/ts/cjs/crypto.js.map +1 -1
- package/ts/cjs/future.d.ts.map +1 -1
- package/ts/cjs/future.js.map +1 -1
- package/ts/cjs/http_header.d.ts.map +1 -1
- package/ts/cjs/http_header.js.map +1 -1
- package/ts/cjs/index.d.ts +1 -0
- package/ts/cjs/index.d.ts.map +1 -1
- package/ts/cjs/index.js +1 -0
- package/ts/cjs/index.js.map +1 -1
- package/ts/cjs/is-json.d.ts.map +1 -1
- package/ts/cjs/is-json.js.map +1 -1
- package/ts/cjs/is-promise.d.ts.map +1 -1
- package/ts/cjs/is-promise.js.map +1 -1
- package/ts/cjs/keyed-ng.d.ts +51 -0
- package/ts/cjs/keyed-ng.d.ts.map +1 -0
- package/ts/cjs/keyed-ng.js +93 -0
- package/ts/cjs/keyed-ng.js.map +1 -0
- package/ts/cjs/keyed-ng.test.d.ts +2 -0
- package/ts/cjs/keyed-ng.test.d.ts.map +1 -0
- package/ts/cjs/keyed-ng.test.js +151 -0
- package/ts/cjs/keyed-ng.test.js.map +1 -0
- package/ts/cjs/lru-map-set.d.ts +4 -1
- package/ts/cjs/lru-map-set.d.ts.map +1 -1
- package/ts/cjs/lru-map-set.js +2 -1
- package/ts/cjs/lru-map-set.js.map +1 -1
- package/ts/cjs/on-func.d.ts.map +1 -1
- package/ts/cjs/on-func.js.map +1 -1
- package/ts/cjs/option.d.ts.map +1 -1
- package/ts/cjs/option.js.map +1 -1
- package/ts/cjs/poller.d.ts +9 -2
- package/ts/cjs/poller.d.ts.map +1 -1
- package/ts/cjs/poller.js +8 -3
- package/ts/cjs/poller.js.map +1 -1
- package/ts/cjs/promise-sleep.d.ts.map +1 -1
- package/ts/cjs/promise-sleep.js.map +1 -1
- package/ts/cjs/resolve-once.d.ts +31 -34
- package/ts/cjs/resolve-once.d.ts.map +1 -1
- package/ts/cjs/resolve-once.js +84 -43
- package/ts/cjs/resolve-once.js.map +1 -1
- package/ts/cjs/resolve-once.test.js +119 -31
- package/ts/cjs/resolve-once.test.js.map +1 -1
- package/ts/cjs/result.d.ts.map +1 -1
- package/ts/cjs/result.js.map +1 -1
- package/ts/cjs/runtime.d.ts.map +1 -1
- package/ts/cjs/runtime.js.map +1 -1
- package/ts/cjs/sys-env.d.ts.map +1 -1
- package/ts/cjs/sys-env.js.map +1 -1
- package/ts/cjs/timeouted.d.ts.map +1 -1
- package/ts/cjs/timeouted.js.map +1 -1
- package/ts/cjs/tracer.d.ts.map +1 -1
- package/ts/cjs/tracer.js.map +1 -1
- package/ts/cjs/txt-en-decoder.d.ts +1 -1
- package/ts/cjs/txt-en-decoder.d.ts.map +1 -1
- package/ts/cjs/txt-en-decoder.js +2 -5
- package/ts/cjs/txt-en-decoder.js.map +1 -1
- package/ts/cjs/uri.d.ts.map +1 -1
- package/ts/cjs/uri.js.map +1 -1
- package/ts/cjs/utils/coerce-uint8.d.ts.map +1 -1
- package/ts/cjs/utils/coerce-uint8.js.map +1 -1
- package/ts/cjs/utils/console-write-stream.d.ts.map +1 -1
- package/ts/cjs/utils/console-write-stream.js.map +1 -1
- package/ts/cjs/utils/consume.d.ts.map +1 -1
- package/ts/cjs/utils/consume.js.map +1 -1
- package/ts/cjs/utils/fanout-write-stream.d.ts.map +1 -1
- package/ts/cjs/utils/fanout-write-stream.js.map +1 -1
- package/ts/cjs/utils/get-params-result.d.ts.map +1 -1
- package/ts/cjs/utils/get-params-result.js.map +1 -1
- package/ts/cjs/utils/rebuffer.d.ts.map +1 -1
- package/ts/cjs/utils/rebuffer.js.map +1 -1
- package/ts/cjs/utils/relative-path.d.ts.map +1 -1
- package/ts/cjs/utils/relative-path.js.map +1 -1
- package/ts/cjs/utils/sorted-object.d.ts.map +1 -1
- package/ts/cjs/utils/sorted-object.js.map +1 -1
- package/ts/cjs/utils/stream-map.d.ts.map +1 -1
- package/ts/cjs/utils/stream-map.js.map +1 -1
- package/ts/cjs/utils/stream2string.d.ts.map +1 -1
- package/ts/cjs/utils/stream2string.js.map +1 -1
- package/ts/cjs/utils/string2stream.d.ts.map +1 -1
- package/ts/cjs/utils/string2stream.js.map +1 -1
- package/ts/cjs/utils/stripper.d.ts.map +1 -1
- package/ts/cjs/utils/stripper.js.map +1 -1
- package/ts/cjs/utils/to-sorted.d.ts.map +1 -1
- package/ts/cjs/utils/to-sorted.js.map +1 -1
- package/ts/cjs/utils/uint8array-equal.d.ts.map +1 -1
- package/ts/cjs/utils/uint8array-equal.js.map +1 -1
- package/ts/cjs/version.d.ts.map +1 -1
- package/ts/cjs/version.js +1 -1
- package/ts/cjs/version.js.map +1 -1
- package/ts/esm/app-context.d.ts.map +1 -1
- package/ts/esm/app-context.js.map +1 -1
- package/ts/esm/base-sys-abstraction.d.ts.map +1 -1
- package/ts/esm/base-sys-abstraction.js.map +1 -1
- package/ts/esm/bin2text.d.ts.map +1 -1
- package/ts/esm/bin2text.js.map +1 -1
- package/ts/esm/coerce-binary.d.ts.map +1 -1
- package/ts/esm/coerce-binary.js.map +1 -1
- package/ts/esm/crypto.d.ts.map +1 -1
- package/ts/esm/crypto.js.map +1 -1
- package/ts/esm/future.d.ts.map +1 -1
- package/ts/esm/future.js.map +1 -1
- package/ts/esm/http_header.d.ts.map +1 -1
- package/ts/esm/http_header.js.map +1 -1
- package/ts/esm/index.d.ts +1 -0
- package/ts/esm/index.d.ts.map +1 -1
- package/ts/esm/index.js +1 -0
- package/ts/esm/index.js.map +1 -1
- package/ts/esm/is-json.d.ts.map +1 -1
- package/ts/esm/is-json.js.map +1 -1
- package/ts/esm/is-promise.d.ts.map +1 -1
- package/ts/esm/is-promise.js.map +1 -1
- package/ts/esm/keyed-ng.d.ts +51 -0
- package/ts/esm/keyed-ng.d.ts.map +1 -0
- package/ts/esm/keyed-ng.js +89 -0
- package/ts/esm/keyed-ng.js.map +1 -0
- package/ts/esm/keyed-ng.test.d.ts +2 -0
- package/ts/esm/keyed-ng.test.d.ts.map +1 -0
- package/ts/esm/keyed-ng.test.js +149 -0
- package/ts/esm/keyed-ng.test.js.map +1 -0
- package/ts/esm/lru-map-set.d.ts +4 -1
- package/ts/esm/lru-map-set.d.ts.map +1 -1
- package/ts/esm/lru-map-set.js +2 -1
- package/ts/esm/lru-map-set.js.map +1 -1
- package/ts/esm/on-func.d.ts.map +1 -1
- package/ts/esm/on-func.js.map +1 -1
- package/ts/esm/option.d.ts.map +1 -1
- package/ts/esm/option.js.map +1 -1
- package/ts/esm/poller.d.ts +9 -2
- package/ts/esm/poller.d.ts.map +1 -1
- package/ts/esm/poller.js +8 -3
- package/ts/esm/poller.js.map +1 -1
- package/ts/esm/promise-sleep.d.ts.map +1 -1
- package/ts/esm/promise-sleep.js.map +1 -1
- package/ts/esm/resolve-once.d.ts +31 -34
- package/ts/esm/resolve-once.d.ts.map +1 -1
- package/ts/esm/resolve-once.js +83 -41
- package/ts/esm/resolve-once.js.map +1 -1
- package/ts/esm/resolve-once.test.js +119 -31
- package/ts/esm/resolve-once.test.js.map +1 -1
- package/ts/esm/result.d.ts.map +1 -1
- package/ts/esm/result.js.map +1 -1
- package/ts/esm/runtime.d.ts.map +1 -1
- package/ts/esm/runtime.js.map +1 -1
- package/ts/esm/sys-env.d.ts.map +1 -1
- package/ts/esm/sys-env.js.map +1 -1
- package/ts/esm/timeouted.d.ts.map +1 -1
- package/ts/esm/timeouted.js.map +1 -1
- package/ts/esm/tracer.d.ts.map +1 -1
- package/ts/esm/tracer.js.map +1 -1
- package/ts/esm/txt-en-decoder.d.ts +1 -1
- package/ts/esm/txt-en-decoder.d.ts.map +1 -1
- package/ts/esm/txt-en-decoder.js +2 -5
- package/ts/esm/txt-en-decoder.js.map +1 -1
- package/ts/esm/uri.d.ts.map +1 -1
- package/ts/esm/uri.js.map +1 -1
- package/ts/esm/utils/coerce-uint8.d.ts.map +1 -1
- package/ts/esm/utils/coerce-uint8.js.map +1 -1
- package/ts/esm/utils/console-write-stream.d.ts.map +1 -1
- package/ts/esm/utils/console-write-stream.js.map +1 -1
- package/ts/esm/utils/consume.d.ts.map +1 -1
- package/ts/esm/utils/consume.js.map +1 -1
- package/ts/esm/utils/fanout-write-stream.d.ts.map +1 -1
- package/ts/esm/utils/fanout-write-stream.js.map +1 -1
- package/ts/esm/utils/get-params-result.d.ts.map +1 -1
- package/ts/esm/utils/get-params-result.js.map +1 -1
- package/ts/esm/utils/rebuffer.d.ts.map +1 -1
- package/ts/esm/utils/rebuffer.js.map +1 -1
- package/ts/esm/utils/relative-path.d.ts.map +1 -1
- package/ts/esm/utils/relative-path.js.map +1 -1
- package/ts/esm/utils/sorted-object.d.ts.map +1 -1
- package/ts/esm/utils/sorted-object.js.map +1 -1
- package/ts/esm/utils/stream-map.d.ts.map +1 -1
- package/ts/esm/utils/stream-map.js.map +1 -1
- package/ts/esm/utils/stream2string.d.ts.map +1 -1
- package/ts/esm/utils/stream2string.js.map +1 -1
- package/ts/esm/utils/string2stream.d.ts.map +1 -1
- package/ts/esm/utils/string2stream.js.map +1 -1
- package/ts/esm/utils/stripper.d.ts.map +1 -1
- package/ts/esm/utils/stripper.js.map +1 -1
- package/ts/esm/utils/to-sorted.d.ts.map +1 -1
- package/ts/esm/utils/to-sorted.js.map +1 -1
- package/ts/esm/utils/uint8array-equal.d.ts.map +1 -1
- package/ts/esm/utils/uint8array-equal.js.map +1 -1
- package/ts/esm/version.d.ts.map +1 -1
- package/ts/esm/version.js +1 -1
- package/ts/esm/version.js.map +1 -1
|
@@ -17,6 +17,11 @@ import { CFBasicSysAbstraction } from "./cf/cf-basic-sys-abstraction.js";
|
|
|
17
17
|
import { DenoBasicSysAbstraction } from "./deno/deno-basic-sys-abstraction.js";
|
|
18
18
|
import { NodeBasicSysAbstraction } from "./node/node-basic-sys-abstraction.js";
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Real-time implementation using system clock.
|
|
22
|
+
*
|
|
23
|
+
* Provides actual current time and real delays. Use for production code.
|
|
24
|
+
*/
|
|
20
25
|
export class SysTime extends Time {
|
|
21
26
|
Now(): Date {
|
|
22
27
|
return new Date();
|
|
@@ -30,6 +35,12 @@ export class SysTime extends Time {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Constant time implementation for deterministic testing.
|
|
40
|
+
*
|
|
41
|
+
* Always returns the same fixed date (2021-02-01). Sleep operations
|
|
42
|
+
* complete immediately without delay. Useful for reproducible tests.
|
|
43
|
+
*/
|
|
33
44
|
export class ConstTime extends Time {
|
|
34
45
|
Now(): Date {
|
|
35
46
|
return new Date(2021, 1, 1, 0, 0, 0, 0);
|
|
@@ -40,6 +51,12 @@ export class ConstTime extends Time {
|
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Stepped time implementation for controlled testing.
|
|
56
|
+
*
|
|
57
|
+
* Advances time in 1-second increments on each Now() call. Sleep operations
|
|
58
|
+
* advance time without delay. Useful for testing time-dependent behavior.
|
|
59
|
+
*/
|
|
43
60
|
export class StepTime extends Time {
|
|
44
61
|
_step: Date;
|
|
45
62
|
readonly _start: Date;
|
|
@@ -68,6 +85,24 @@ export class StepTime extends Time {
|
|
|
68
85
|
}
|
|
69
86
|
}
|
|
70
87
|
|
|
88
|
+
/**
|
|
89
|
+
* Creates a Time implementation based on the specified mode.
|
|
90
|
+
*
|
|
91
|
+
* @param timeMode - Time behavior mode (REAL, CONST, or STEP)
|
|
92
|
+
* @returns Time implementation matching the mode
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* // Production: uses real system time
|
|
97
|
+
* const realTime = TimeFactory(TimeMode.REAL);
|
|
98
|
+
*
|
|
99
|
+
* // Testing: constant time
|
|
100
|
+
* const constTime = TimeFactory(TimeMode.CONST);
|
|
101
|
+
*
|
|
102
|
+
* // Testing: stepped time
|
|
103
|
+
* const stepTime = TimeFactory(TimeMode.STEP);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
71
106
|
export function TimeFactory(timeMode: TimeMode): Time {
|
|
72
107
|
switch (timeMode) {
|
|
73
108
|
case TimeMode.REAL:
|
|
@@ -80,12 +115,42 @@ export function TimeFactory(timeMode: TimeMode): Time {
|
|
|
80
115
|
return new SysTime();
|
|
81
116
|
}
|
|
82
117
|
|
|
118
|
+
/**
|
|
119
|
+
* Random number generator with deterministic modes for testing.
|
|
120
|
+
*
|
|
121
|
+
* Provides random number generation that can operate in different modes:
|
|
122
|
+
* - RANDOM: Uses Math.random() for real random values
|
|
123
|
+
* - CONST: Always returns a constant value (0.5 * max) for reproducible tests
|
|
124
|
+
* - STEP: Returns incrementing values for predictable test sequences
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```typescript
|
|
128
|
+
* // Production: real randomness
|
|
129
|
+
* const random = new RandomService(RandomMode.RANDOM);
|
|
130
|
+
* const value = random.Random0ToValue(100); // 0-100
|
|
131
|
+
*
|
|
132
|
+
* // Testing: constant value
|
|
133
|
+
* const constRandom = new RandomService(RandomMode.CONST);
|
|
134
|
+
* const value = constRandom.Random0ToValue(100); // Always 50
|
|
135
|
+
*
|
|
136
|
+
* // Testing: stepped sequence
|
|
137
|
+
* const stepRandom = new RandomService(RandomMode.STEP);
|
|
138
|
+
* const v1 = stepRandom.Random0ToValue(100); // 0.01
|
|
139
|
+
* const v2 = stepRandom.Random0ToValue(100); // 0.02
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
83
142
|
export class RandomService {
|
|
84
143
|
readonly _mode: RandomMode;
|
|
85
144
|
_step = 0;
|
|
86
145
|
constructor(mode: RandomMode) {
|
|
87
146
|
this._mode = mode;
|
|
88
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Generates a random number between 0 and the specified value.
|
|
150
|
+
*
|
|
151
|
+
* @param value - Maximum value (exclusive upper bound)
|
|
152
|
+
* @returns Random number in range [0, value)
|
|
153
|
+
*/
|
|
89
154
|
Random0ToValue(value: number): number {
|
|
90
155
|
switch (this._mode) {
|
|
91
156
|
case RandomMode.CONST:
|
|
@@ -101,6 +166,31 @@ export class RandomService {
|
|
|
101
166
|
}
|
|
102
167
|
}
|
|
103
168
|
|
|
169
|
+
/**
|
|
170
|
+
* ID generator with deterministic modes for testing.
|
|
171
|
+
*
|
|
172
|
+
* Generates unique identifiers with support for different modes:
|
|
173
|
+
* - UUID: Uses crypto.randomUUID() for real UUIDs (default)
|
|
174
|
+
* - CONST: Always returns the same constant ID for reproducible tests
|
|
175
|
+
* - STEP: Returns incrementing IDs (STEPId-0, STEPId-1, etc.) for predictable sequences
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```typescript
|
|
179
|
+
* // Production: real UUIDs
|
|
180
|
+
* const idService = new IdService(IDMode.UUID);
|
|
181
|
+
* const id = idService.NextId(); // "550e8400-e29b-41d4-a716-446655440000"
|
|
182
|
+
*
|
|
183
|
+
* // Testing: constant ID
|
|
184
|
+
* const constId = new IdService(IDMode.CONST);
|
|
185
|
+
* const id1 = constId.NextId(); // "VeryUniqueID"
|
|
186
|
+
* const id2 = constId.NextId(); // "VeryUniqueID"
|
|
187
|
+
*
|
|
188
|
+
* // Testing: stepped sequence
|
|
189
|
+
* const stepId = new IdService(IDMode.STEP);
|
|
190
|
+
* const id1 = stepId.NextId(); // "STEPId-0"
|
|
191
|
+
* const id2 = stepId.NextId(); // "STEPId-1"
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
104
194
|
export class IdService {
|
|
105
195
|
readonly _mode: IDMode;
|
|
106
196
|
_step = 0;
|
|
@@ -110,6 +200,11 @@ export class IdService {
|
|
|
110
200
|
}
|
|
111
201
|
this._mode = mode;
|
|
112
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Generates the next unique identifier.
|
|
205
|
+
*
|
|
206
|
+
* @returns Unique ID string based on the configured mode
|
|
207
|
+
*/
|
|
113
208
|
NextId(): string {
|
|
114
209
|
switch (this._mode) {
|
|
115
210
|
case IDMode.UUID:
|
|
@@ -145,6 +240,29 @@ export interface ExitService {
|
|
|
145
240
|
|
|
146
241
|
// some black magic to make it work with CF workers
|
|
147
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Base system abstraction for platform-independent services.
|
|
245
|
+
*
|
|
246
|
+
* Provides core services that work across all JavaScript runtimes:
|
|
247
|
+
* - Time: Real system time implementation
|
|
248
|
+
* - ID Generation: UUID-based unique identifiers
|
|
249
|
+
* - Random Numbers: Math.random()-based generation
|
|
250
|
+
* - Text Encoding/Decoding: UTF-8 conversion utilities
|
|
251
|
+
*
|
|
252
|
+
* This is the foundation for both basic and full system abstractions,
|
|
253
|
+
* containing services that don't require filesystem or system access.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* const base = new BaseBasicSysAbstraction({
|
|
258
|
+
* TxtEnDecoder: new TxtEnDecoder()
|
|
259
|
+
* });
|
|
260
|
+
*
|
|
261
|
+
* const now = base._time.Now();
|
|
262
|
+
* const id = base._idService.NextId();
|
|
263
|
+
* const random = base._randomService.Random0ToValue(100);
|
|
264
|
+
* ```
|
|
265
|
+
*/
|
|
148
266
|
export class BaseBasicSysAbstraction {
|
|
149
267
|
readonly _time: SysTime = new SysTime();
|
|
150
268
|
|
|
@@ -158,6 +276,31 @@ export class BaseBasicSysAbstraction {
|
|
|
158
276
|
}
|
|
159
277
|
}
|
|
160
278
|
|
|
279
|
+
/**
|
|
280
|
+
* Full system abstraction with filesystem and system service access.
|
|
281
|
+
*
|
|
282
|
+
* Extends BaseBasicSysAbstraction with platform-specific services:
|
|
283
|
+
* - FileSystem: File I/O operations
|
|
284
|
+
* - SystemService: Process, environment, and system-level operations
|
|
285
|
+
*
|
|
286
|
+
* Used in Node.js and Deno environments where full system access is available.
|
|
287
|
+
* Not suitable for browser or Cloudflare Workers environments.
|
|
288
|
+
*
|
|
289
|
+
* @example
|
|
290
|
+
* ```typescript
|
|
291
|
+
* const sys = new BaseSysAbstraction({
|
|
292
|
+
* TxtEnDecoder: new TxtEnDecoder(),
|
|
293
|
+
* FileSystem: new NodeFileService(),
|
|
294
|
+
* SystemService: new NodeSystemService()
|
|
295
|
+
* });
|
|
296
|
+
*
|
|
297
|
+
* // Access filesystem
|
|
298
|
+
* const content = await sys._fileSystem.readFile('/path/to/file');
|
|
299
|
+
*
|
|
300
|
+
* // Access environment
|
|
301
|
+
* const env = sys._systemService.getEnv();
|
|
302
|
+
* ```
|
|
303
|
+
*/
|
|
161
304
|
export class BaseSysAbstraction extends BaseBasicSysAbstraction {
|
|
162
305
|
// system related services
|
|
163
306
|
readonly _fileSystem: FileService;
|
|
@@ -182,6 +325,36 @@ export interface BasicSysAbstractionParams {
|
|
|
182
325
|
|
|
183
326
|
export type WrapperBasicSysAbstractionParams = Partial<BasicRuntimeService & BasicSysAbstractionParams>;
|
|
184
327
|
|
|
328
|
+
/**
|
|
329
|
+
* Creates a BasicSysAbstraction instance for the current runtime environment.
|
|
330
|
+
*
|
|
331
|
+
* Automatically detects the JavaScript runtime (Browser, Node.js, Deno, or
|
|
332
|
+
* Cloudflare Workers) and returns the appropriate system abstraction implementation.
|
|
333
|
+
* Supports optional configuration for time, ID, and random number generation modes,
|
|
334
|
+
* useful for testing with deterministic behavior.
|
|
335
|
+
*
|
|
336
|
+
* @param params - Optional configuration for time, ID, and random modes
|
|
337
|
+
* @returns BasicSysAbstraction instance for the current runtime
|
|
338
|
+
* @throws Error if the runtime cannot be detected
|
|
339
|
+
*
|
|
340
|
+
* @example
|
|
341
|
+
* ```typescript
|
|
342
|
+
* // Production: auto-detect runtime with defaults
|
|
343
|
+
* const sys = BasicSysAbstractionFactory();
|
|
344
|
+
* const now = sys.Time().Now();
|
|
345
|
+
* const id = sys.NextId();
|
|
346
|
+
*
|
|
347
|
+
* // Testing: deterministic behavior
|
|
348
|
+
* const testSys = BasicSysAbstractionFactory({
|
|
349
|
+
* TimeMode: TimeMode.CONST,
|
|
350
|
+
* IdMode: IDMode.STEP,
|
|
351
|
+
* RandomMode: RandomMode.CONST
|
|
352
|
+
* });
|
|
353
|
+
* const constTime = testSys.Time().Now(); // Always 2021-02-01
|
|
354
|
+
* const id1 = testSys.NextId(); // "STEPId-0"
|
|
355
|
+
* const id2 = testSys.NextId(); // "STEPId-1"
|
|
356
|
+
* ```
|
|
357
|
+
*/
|
|
185
358
|
export function BasicSysAbstractionFactory(params?: WrapperBasicSysAbstractionParams): BasicSysAbstraction {
|
|
186
359
|
const fn = runtimeFn();
|
|
187
360
|
switch (true) {
|
|
@@ -198,6 +371,44 @@ export function BasicSysAbstractionFactory(params?: WrapperBasicSysAbstractionPa
|
|
|
198
371
|
}
|
|
199
372
|
}
|
|
200
373
|
|
|
374
|
+
/**
|
|
375
|
+
* BasicSysAbstraction implementation with configurable service modes.
|
|
376
|
+
*
|
|
377
|
+
* Wraps a base system abstraction and allows overriding time, ID, and random
|
|
378
|
+
* number generation modes. This is the primary implementation returned by
|
|
379
|
+
* BasicSysAbstractionFactory and provides the unified interface for all
|
|
380
|
+
* platform-independent system services.
|
|
381
|
+
*
|
|
382
|
+
* Delegates runtime-specific operations (Stdout, Stderr, Env, Args) to the
|
|
383
|
+
* underlying runtime service while providing configurable implementations for
|
|
384
|
+
* testable services (Time, ID, Random).
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```typescript
|
|
388
|
+
* // Created via factory
|
|
389
|
+
* const sys = BasicSysAbstractionFactory({
|
|
390
|
+
* TimeMode: TimeMode.STEP,
|
|
391
|
+
* IdMode: IDMode.UUID,
|
|
392
|
+
* RandomMode: RandomMode.RANDOM
|
|
393
|
+
* });
|
|
394
|
+
*
|
|
395
|
+
* // Use time service
|
|
396
|
+
* const time = sys.Time();
|
|
397
|
+
* const now = time.Now();
|
|
398
|
+
* await time.Sleep(1000);
|
|
399
|
+
*
|
|
400
|
+
* // Use ID service
|
|
401
|
+
* const id = sys.NextId();
|
|
402
|
+
*
|
|
403
|
+
* // Use random service
|
|
404
|
+
* const random = sys.Random0ToValue(100);
|
|
405
|
+
*
|
|
406
|
+
* // Access runtime services
|
|
407
|
+
* const stdout = sys.Stdout();
|
|
408
|
+
* const env = sys.Env();
|
|
409
|
+
* const args = sys.Args();
|
|
410
|
+
* ```
|
|
411
|
+
*/
|
|
201
412
|
export class WrapperBasicSysAbstraction implements BasicSysAbstraction {
|
|
202
413
|
readonly _time: Time;
|
|
203
414
|
readonly _idService: IdService;
|
|
@@ -253,6 +464,39 @@ export class WrapperBasicSysAbstraction implements BasicSysAbstraction {
|
|
|
253
464
|
}
|
|
254
465
|
// export const BaseSysAbstraction = new BaseSysAbstractionImpl()
|
|
255
466
|
|
|
467
|
+
/**
|
|
468
|
+
* Full system abstraction with filesystem and system service access.
|
|
469
|
+
*
|
|
470
|
+
* Extends WrapperBasicSysAbstraction with filesystem and system services,
|
|
471
|
+
* providing the complete system abstraction interface. Used in environments
|
|
472
|
+
* with full system access (Node.js, Deno) where filesystem operations,
|
|
473
|
+
* process management, and environment access are available.
|
|
474
|
+
*
|
|
475
|
+
* Inherits all configurable services from WrapperBasicSysAbstraction (Time,
|
|
476
|
+
* ID, Random) and adds FileSystem and SystemService access.
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```typescript
|
|
480
|
+
* // Created via runtime-specific factory
|
|
481
|
+
* const sys = NodeSysAbstraction({
|
|
482
|
+
* TimeMode: TimeMode.REAL,
|
|
483
|
+
* IdMode: IDMode.UUID
|
|
484
|
+
* });
|
|
485
|
+
*
|
|
486
|
+
* // Use basic services
|
|
487
|
+
* const time = sys.Time();
|
|
488
|
+
* const id = sys.NextId();
|
|
489
|
+
*
|
|
490
|
+
* // Use filesystem
|
|
491
|
+
* const fs = sys.FileSystem();
|
|
492
|
+
* const content = await fs.readFile('/path/to/file');
|
|
493
|
+
*
|
|
494
|
+
* // Use system services
|
|
495
|
+
* const system = sys.System();
|
|
496
|
+
* const env = system.getEnv();
|
|
497
|
+
* system.exit(0);
|
|
498
|
+
* ```
|
|
499
|
+
*/
|
|
256
500
|
export class WrapperRuntimeSysAbstraction extends WrapperBasicSysAbstraction {
|
|
257
501
|
readonly _systemService: SystemService;
|
|
258
502
|
readonly _fileSystem: FileService;
|
package/src/bin2text.ts
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Formats binary data as hexdump output with ASCII representation.
|
|
3
|
+
*
|
|
4
|
+
* Produces hexdump-style output similar to `xxd` or `hexdump` commands,
|
|
5
|
+
* showing hex values and ASCII characters side-by-side. Each line shows
|
|
6
|
+
* 16 bytes with offset, hex values, and printable ASCII characters.
|
|
7
|
+
*
|
|
8
|
+
* @param hex - Binary data to format (any ArrayBufferView)
|
|
9
|
+
* @param lineFn - Callback function invoked for each formatted line
|
|
10
|
+
* @param size - Maximum number of bytes to format (0 = all bytes)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const data = new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]);
|
|
15
|
+
* bin2text(data, (line) => console.log(line));
|
|
16
|
+
* // Output:
|
|
17
|
+
* // 0000 48 65 6c 6c 6f 20 57 6f 72 6c 64 Hello World
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
1
20
|
export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, size = 0): void {
|
|
2
21
|
const arr = new Uint8Array(hex.buffer, hex.byteOffset, hex.byteLength);
|
|
3
22
|
let cutted = " ";
|
|
@@ -34,6 +53,24 @@ export function bin2text(hex: ArrayBufferView, lineFn: (line: string) => void, s
|
|
|
34
53
|
}
|
|
35
54
|
}
|
|
36
55
|
|
|
56
|
+
/**
|
|
57
|
+
* Formats binary data as a hexdump string.
|
|
58
|
+
*
|
|
59
|
+
* Convenience wrapper around bin2text that returns a single string with
|
|
60
|
+
* newline-separated hexdump lines. Useful for logging or display purposes.
|
|
61
|
+
*
|
|
62
|
+
* @param hex - Binary data to format (any ArrayBufferView)
|
|
63
|
+
* @param size - Maximum number of bytes to format (0 = all bytes)
|
|
64
|
+
* @returns Formatted hexdump as a string
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```typescript
|
|
68
|
+
* const data = new Uint8Array([72, 101, 108, 108, 111]);
|
|
69
|
+
* const dump = bin2string(data);
|
|
70
|
+
* console.log(dump);
|
|
71
|
+
* // 0000 48 65 6c 6c 6f Hello
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
37
74
|
export function bin2string(hex: ArrayBufferView, size = 0): string {
|
|
38
75
|
const collector: string[] = [];
|
|
39
76
|
bin2text(
|
package/src/coerce-binary.ts
CHANGED
|
@@ -2,14 +2,32 @@ import { TxtEnDecoderSingleton } from "./txt-en-decoder.js";
|
|
|
2
2
|
|
|
3
3
|
export type CoerceBinaryInput = string | ArrayBufferLike | ArrayBufferView | Uint8Array; // | SharedArrayBuffer
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Type guard to check if a value is an ArrayBuffer.
|
|
7
|
+
*
|
|
8
|
+
* @param value - The value to check
|
|
9
|
+
* @returns True if the value is an ArrayBuffer
|
|
10
|
+
*/
|
|
5
11
|
export function isArrayBuffer(value: unknown): value is ArrayBuffer {
|
|
6
12
|
return value instanceof ArrayBuffer || Object.prototype.toString.call(value) === "[object ArrayBuffer]";
|
|
7
13
|
}
|
|
8
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Type guard to check if a value is a Uint8Array.
|
|
17
|
+
*
|
|
18
|
+
* @param value - The value to check
|
|
19
|
+
* @returns True if the value is a Uint8Array
|
|
20
|
+
*/
|
|
9
21
|
export function isUint8Array(value: unknown): value is Uint8Array {
|
|
10
22
|
return value instanceof Uint8Array || Object.prototype.toString.call(value) === "[object Uint8Array]";
|
|
11
23
|
}
|
|
12
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Converts various binary input types (including Blob) to Uint8Array asynchronously.
|
|
27
|
+
*
|
|
28
|
+
* @param input - String, ArrayBuffer, ArrayBufferView, Uint8Array, or Blob to convert
|
|
29
|
+
* @returns Promise resolving to Uint8Array
|
|
30
|
+
*/
|
|
13
31
|
export async function top_uint8(input: CoerceBinaryInput | Blob): Promise<Uint8Array> {
|
|
14
32
|
if (input instanceof Blob) {
|
|
15
33
|
return new Uint8Array(await input.arrayBuffer());
|
|
@@ -17,6 +35,15 @@ export async function top_uint8(input: CoerceBinaryInput | Blob): Promise<Uint8A
|
|
|
17
35
|
return to_uint8(input);
|
|
18
36
|
}
|
|
19
37
|
|
|
38
|
+
/**
|
|
39
|
+
* Converts various binary input types to Uint8Array synchronously.
|
|
40
|
+
*
|
|
41
|
+
* Handles strings (encoding with TextEncoder), ArrayBuffers, and ArrayBufferViews.
|
|
42
|
+
*
|
|
43
|
+
* @param input - String, ArrayBuffer, ArrayBufferView, or Uint8Array to convert
|
|
44
|
+
* @param encoder - Optional TextEncoder instance (uses singleton if not provided)
|
|
45
|
+
* @returns Uint8Array representation of the input
|
|
46
|
+
*/
|
|
20
47
|
export function to_uint8(input: CoerceBinaryInput, encoder?: TextEncoder): Uint8Array {
|
|
21
48
|
if (typeof input === "string") {
|
|
22
49
|
return (encoder ?? TxtEnDecoderSingleton()).encode(input);
|
|
@@ -32,6 +59,13 @@ export function to_uint8(input: CoerceBinaryInput, encoder?: TextEncoder): Uint8
|
|
|
32
59
|
return new Uint8Array(input as unknown as ArrayBufferLike);
|
|
33
60
|
}
|
|
34
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Converts various binary input types to Blob.
|
|
64
|
+
*
|
|
65
|
+
* @param input - String, ArrayBuffer, ArrayBufferView, Uint8Array, or Blob to convert
|
|
66
|
+
* @param encoder - Optional TextEncoder instance (uses singleton if not provided)
|
|
67
|
+
* @returns Blob representation of the input
|
|
68
|
+
*/
|
|
35
69
|
export function to_blob(input: CoerceBinaryInput | Blob, encoder?: TextEncoder): Blob {
|
|
36
70
|
if (input instanceof Blob) {
|
|
37
71
|
return input;
|
|
@@ -40,6 +74,13 @@ export function to_blob(input: CoerceBinaryInput | Blob, encoder?: TextEncoder):
|
|
|
40
74
|
return new Blob([ab]);
|
|
41
75
|
}
|
|
42
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Converts various binary input types to ArrayBuffer.
|
|
79
|
+
*
|
|
80
|
+
* @param input - String, ArrayBuffer, ArrayBufferView, or Uint8Array to convert
|
|
81
|
+
* @param encoder - Optional TextEncoder instance (uses singleton if not provided)
|
|
82
|
+
* @returns ArrayBuffer representation of the input
|
|
83
|
+
*/
|
|
43
84
|
export function to_arraybuf(input: CoerceBinaryInput, encoder?: TextEncoder): ArrayBuffer {
|
|
44
85
|
if (input instanceof ArrayBuffer) {
|
|
45
86
|
return input;
|
package/src/crypto.ts
CHANGED
|
@@ -123,6 +123,41 @@ function digestSHA256(crypto: typeof globalThis.crypto): (data: Uint8Array) => P
|
|
|
123
123
|
};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Creates a CryptoRuntime abstraction with optional custom implementations.
|
|
128
|
+
*
|
|
129
|
+
* Provides a unified crypto interface that works across different JavaScript
|
|
130
|
+
* runtimes (browsers, Node.js, Deno, CF Workers). Automatically uses the global
|
|
131
|
+
* Web Crypto API when available, with fallback implementations that throw errors
|
|
132
|
+
* for unavailable operations. Allows overriding any method for testing or
|
|
133
|
+
* custom implementations.
|
|
134
|
+
*
|
|
135
|
+
* @param cryptoOpts - Optional custom implementations for crypto operations
|
|
136
|
+
* @returns CryptoRuntime instance with crypto operations
|
|
137
|
+
*
|
|
138
|
+
* @example
|
|
139
|
+
* ```typescript
|
|
140
|
+
* // Use default global crypto
|
|
141
|
+
* const crypto = toCryptoRuntime();
|
|
142
|
+
* const hash = await crypto.digestSHA256(new Uint8Array([1, 2, 3]));
|
|
143
|
+
* const randomData = crypto.randomBytes(16);
|
|
144
|
+
*
|
|
145
|
+
* // Override for testing
|
|
146
|
+
* const mockCrypto = toCryptoRuntime({
|
|
147
|
+
* randomBytes: (size) => new Uint8Array(size).fill(42),
|
|
148
|
+
* digestSHA256: async (data) => new ArrayBuffer(32)
|
|
149
|
+
* });
|
|
150
|
+
*
|
|
151
|
+
* // Encrypt/decrypt with AES-GCM
|
|
152
|
+
* const key = await crypto.importKey(
|
|
153
|
+
* 'raw',
|
|
154
|
+
* new Uint8Array(32),
|
|
155
|
+
* { name: 'AES-GCM' },
|
|
156
|
+
* false,
|
|
157
|
+
* ['encrypt', 'decrypt']
|
|
158
|
+
* );
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
126
161
|
export function toCryptoRuntime(cryptoOpts: Partial<CryptoRuntime> = {}): CryptoRuntime {
|
|
127
162
|
let crypto: typeof globalThis.crypto;
|
|
128
163
|
if (!globalThis.crypto || !globalThis.crypto.subtle) {
|
package/src/future.ts
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
import { Lazy } from "./resolve-once.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* A Promise that can be resolved or rejected externally after creation.
|
|
5
|
+
*
|
|
6
|
+
* Future provides a way to create a Promise whose resolution is controlled
|
|
7
|
+
* externally rather than in the executor function. This is useful for
|
|
8
|
+
* coordinating async operations, implementing custom async primitives,
|
|
9
|
+
* or bridging callback-based APIs to promises.
|
|
10
|
+
*
|
|
11
|
+
* @template T - The type of the resolved value
|
|
12
|
+
* @template CTX - Optional context type for additional data
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const future = new Future<string>();
|
|
17
|
+
*
|
|
18
|
+
* // Later, resolve it from anywhere
|
|
19
|
+
* future.resolve('hello');
|
|
20
|
+
*
|
|
21
|
+
* // Or reject it
|
|
22
|
+
* future.reject(new Error('failed'));
|
|
23
|
+
*
|
|
24
|
+
* // Use it like a promise
|
|
25
|
+
* const result = await future.asPromise();
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
3
28
|
export class Future<T, CTX = void> {
|
|
4
29
|
// readonly id = Math.random();
|
|
5
30
|
readonly #promise: Promise<T>;
|
|
@@ -19,16 +44,35 @@ export class Future<T, CTX = void> {
|
|
|
19
44
|
});
|
|
20
45
|
}
|
|
21
46
|
|
|
22
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Lazily-generated unique identifier for this Future.
|
|
49
|
+
* Not cryptographically secure, but suitable for transaction/debug tracking.
|
|
50
|
+
*/
|
|
23
51
|
readonly id: () => string = Lazy(() => Math.random().toString(36).substring(2) + Date.now().toString(36));
|
|
24
52
|
|
|
53
|
+
/**
|
|
54
|
+
* Returns the underlying Promise that will be resolved or rejected.
|
|
55
|
+
*
|
|
56
|
+
* @returns The Promise representation of this Future
|
|
57
|
+
*/
|
|
25
58
|
asPromise(): Promise<T> {
|
|
26
59
|
return this.#promise;
|
|
27
60
|
}
|
|
28
61
|
|
|
62
|
+
/**
|
|
63
|
+
* Resolves the Future with the given value.
|
|
64
|
+
*
|
|
65
|
+
* @param value - The value to resolve the Promise with
|
|
66
|
+
*/
|
|
29
67
|
resolve(value: T): void {
|
|
30
68
|
this.#resolveFn(value);
|
|
31
69
|
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Rejects the Future with the given reason.
|
|
73
|
+
*
|
|
74
|
+
* @param reason - The reason for rejection (typically an Error)
|
|
75
|
+
*/
|
|
32
76
|
reject(reason: unknown): void {
|
|
33
77
|
this.#rejectFn(reason);
|
|
34
78
|
}
|