@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
package/src/result.ts
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
import { isPromise } from "./is-promise.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Result type for representing success (Ok) or failure (Err) values.
|
|
5
|
+
*
|
|
6
|
+
* Result is a type-safe way to handle operations that can fail, similar to Rust's
|
|
7
|
+
* Result type. It forces explicit handling of both success and error cases without
|
|
8
|
+
* throwing exceptions.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The type of the success value
|
|
11
|
+
* @template E - The type of the error (default: Error)
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* function divide(a: number, b: number): Result<number> {
|
|
16
|
+
* if (b === 0) {
|
|
17
|
+
* return Result.Err('Division by zero');
|
|
18
|
+
* }
|
|
19
|
+
* return Result.Ok(a / b);
|
|
20
|
+
* }
|
|
21
|
+
*
|
|
22
|
+
* const result = divide(10, 2);
|
|
23
|
+
* if (result.isOk()) {
|
|
24
|
+
* console.log('Result:', result.unwrap());
|
|
25
|
+
* } else {
|
|
26
|
+
* console.error('Error:', result.unwrap_err());
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
3
30
|
export abstract class Result<T, E = Error> {
|
|
4
31
|
static Ok<T = void>(...args: T[]): Result<T, Error> {
|
|
5
32
|
return args.length >= 1 ? new ResultOK<T>(args[0]) : new ResultOK<T>(undefined as unknown as T);
|
|
@@ -95,6 +122,29 @@ export type WithoutResult<T> = T extends Result<infer U> ? U : T;
|
|
|
95
122
|
// type WithoutPromise<T> = T extends Promise<infer U> ? U : T;
|
|
96
123
|
type WithResult<T> = T extends Promise<infer U> ? Promise<Result<U>> : Result<T>;
|
|
97
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Wraps a function to convert thrown exceptions into Result.Err values.
|
|
127
|
+
*
|
|
128
|
+
* Executes the provided function and returns Result.Ok on success or Result.Err
|
|
129
|
+
* on thrown exceptions. Supports both synchronous and asynchronous functions.
|
|
130
|
+
*
|
|
131
|
+
* @template FN - Function type that returns T or Promise<T>
|
|
132
|
+
* @template T - The return type of the function
|
|
133
|
+
* @param fn - Function to execute with exception handling
|
|
134
|
+
* @returns Result<T> for sync functions, Promise<Result<T>> for async functions
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```typescript
|
|
138
|
+
* const result = exception2Result(() => {
|
|
139
|
+
* return JSON.parse('invalid json');
|
|
140
|
+
* });
|
|
141
|
+
* // result is Result.Err with parse error
|
|
142
|
+
*
|
|
143
|
+
* const asyncResult = await exception2Result(async () => {
|
|
144
|
+
* return await fetch('/api/data');
|
|
145
|
+
* });
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
98
148
|
export function exception2Result<FN extends () => Promise<T> | T, T>(fn: FN): WithResult<ReturnType<FN>> {
|
|
99
149
|
try {
|
|
100
150
|
const res = fn();
|
package/src/runtime.ts
CHANGED
|
@@ -1,11 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime environment detection result.
|
|
3
|
+
*
|
|
4
|
+
* Provides boolean flags indicating which JavaScript runtime environment
|
|
5
|
+
* the code is currently executing in. Only one flag should be true at a time,
|
|
6
|
+
* allowing for runtime-specific behavior and feature detection.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const runtime = runtimeFn();
|
|
11
|
+
* if (runtime.isNodeIsh) {
|
|
12
|
+
* console.log('Running in Node.js or Bun');
|
|
13
|
+
* } else if (runtime.isBrowser) {
|
|
14
|
+
* console.log('Running in a browser');
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
1
18
|
export interface Runtime {
|
|
19
|
+
/** True if running in Node.js or Node-compatible runtime (e.g., Bun) */
|
|
2
20
|
isNodeIsh: boolean;
|
|
21
|
+
/** True if running in a web browser */
|
|
3
22
|
isBrowser: boolean;
|
|
23
|
+
/** True if running in Deno */
|
|
4
24
|
isDeno: boolean;
|
|
25
|
+
/** True if running in React Native */
|
|
5
26
|
isReactNative: boolean;
|
|
27
|
+
/** True if running in Cloudflare Workers */
|
|
6
28
|
isCFWorker: boolean;
|
|
7
29
|
}
|
|
8
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Checks if a nested property path exists on an object.
|
|
33
|
+
*
|
|
34
|
+
* Recursively traverses dot-separated property paths to determine if they exist
|
|
35
|
+
* and are truthy. Used internally for runtime environment detection by checking
|
|
36
|
+
* for environment-specific global objects.
|
|
37
|
+
*
|
|
38
|
+
* @param value - Dot-separated property path to check (e.g., "process.versions.node")
|
|
39
|
+
* @param ref - Object to check properties on (defaults to globalThis)
|
|
40
|
+
* @returns True if the full path exists and all values are truthy
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* isSet("process.versions.node"); // true in Node.js
|
|
45
|
+
* isSet("Deno"); // true in Deno
|
|
46
|
+
* isSet("navigator.userAgent"); // true in browsers
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
9
49
|
function isSet(value: string, ref: Record<string, unknown> = globalThis): boolean {
|
|
10
50
|
const [head, ...tail] = value.split(".");
|
|
11
51
|
if (["object", "function"].includes(typeof ref) && ref && ["object", "function"].includes(typeof ref[head]) && ref[head]) {
|
|
@@ -17,8 +57,41 @@ function isSet(value: string, ref: Record<string, unknown> = globalThis): boolea
|
|
|
17
57
|
return false;
|
|
18
58
|
}
|
|
19
59
|
|
|
20
|
-
|
|
21
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Detects the current JavaScript runtime environment.
|
|
62
|
+
*
|
|
63
|
+
* Performs feature detection to identify which runtime environment the code
|
|
64
|
+
* is executing in. Checks for environment-specific global objects and APIs
|
|
65
|
+
* in priority order:
|
|
66
|
+
* 1. Cloudflare Workers (caches.default + WebSocketPair)
|
|
67
|
+
* 2. React Native (navigator.product === "ReactNative")
|
|
68
|
+
* 3. Deno (global Deno object)
|
|
69
|
+
* 4. Node.js (process.versions.node)
|
|
70
|
+
* 5. Browser (none of the above)
|
|
71
|
+
*
|
|
72
|
+
* The detection is mutually exclusive - only one environment flag will be true.
|
|
73
|
+
*
|
|
74
|
+
* @returns Runtime object with boolean flags for each environment
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const runtime = runtimeFn();
|
|
79
|
+
*
|
|
80
|
+
* if (runtime.isNodeIsh) {
|
|
81
|
+
* // Use Node.js APIs
|
|
82
|
+
* const fs = require('fs');
|
|
83
|
+
* } else if (runtime.isBrowser) {
|
|
84
|
+
* // Use browser APIs
|
|
85
|
+
* console.log(window.location.href);
|
|
86
|
+
* } else if (runtime.isDeno) {
|
|
87
|
+
* // Use Deno APIs
|
|
88
|
+
* const file = await Deno.readTextFile('./config.json');
|
|
89
|
+
* } else if (runtime.isCFWorker) {
|
|
90
|
+
* // Use Cloudflare Workers APIs
|
|
91
|
+
* const cache = caches.default;
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
22
95
|
export function runtimeFn(): Runtime {
|
|
23
96
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
97
|
const gt: any = globalThis;
|
package/src/sys-env.ts
CHANGED
|
@@ -49,6 +49,26 @@ const envActions: { id: string; fn: EnvFactoryFn }[] = [
|
|
|
49
49
|
{ id: "browser", fn: (opts: Partial<EnvFactoryOpts>): EnvActions => BrowserEnvActions.new(opts) },
|
|
50
50
|
];
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Registers a custom environment action factory.
|
|
54
|
+
*
|
|
55
|
+
* Allows registration of platform-specific environment implementations.
|
|
56
|
+
* The factory is added to the beginning of the search list and will be
|
|
57
|
+
* tried first when creating new Env instances.
|
|
58
|
+
*
|
|
59
|
+
* @param fn - Factory function that creates EnvActions for a platform
|
|
60
|
+
* @returns Unregister function to remove the factory
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```typescript
|
|
64
|
+
* const unregister = registerEnvAction((opts) => {
|
|
65
|
+
* return new CustomEnvActions(opts);
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // Later, remove the factory
|
|
69
|
+
* unregister();
|
|
70
|
+
* ```
|
|
71
|
+
*/
|
|
52
72
|
export function registerEnvAction(fn: EnvFactoryFn): () => void {
|
|
53
73
|
const id = `id-${Math.random()}`;
|
|
54
74
|
envActions.unshift({ id, fn });
|
|
@@ -63,6 +83,43 @@ export function registerEnvAction(fn: EnvFactoryFn): () => void {
|
|
|
63
83
|
}
|
|
64
84
|
|
|
65
85
|
const _envFactories = new KeyedResolvOnce<Env>();
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Creates a platform-appropriate environment variable interface.
|
|
89
|
+
*
|
|
90
|
+
* Automatically detects the runtime environment (Node.js, Deno, browser,
|
|
91
|
+
* Cloudflare Workers) and returns an Env instance with platform-specific
|
|
92
|
+
* implementations. Supports preset values, change notifications, and
|
|
93
|
+
* type-safe multi-key retrieval.
|
|
94
|
+
*
|
|
95
|
+
* @param opts - Optional configuration:
|
|
96
|
+
* - symbol: Key for browser environment storage (default: "CP_ENV")
|
|
97
|
+
* - presetEnv: Map of preset environment variables
|
|
98
|
+
* - testPatchImportMetaEnv: Test values to patch into import.meta.env
|
|
99
|
+
* - id: Identifier for caching/reinitialization
|
|
100
|
+
*
|
|
101
|
+
* @returns Env instance for the detected platform
|
|
102
|
+
* @throws Error if no compatible environment is detected
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```typescript
|
|
106
|
+
* const env = envFactory();
|
|
107
|
+
*
|
|
108
|
+
* // Get single value
|
|
109
|
+
* const apiKey = env.get('API_KEY');
|
|
110
|
+
*
|
|
111
|
+
* // Get multiple values with Result
|
|
112
|
+
* const config = env.gets('DB_HOST', 'DB_PORT', 'DB_NAME');
|
|
113
|
+
* if (config.isOk()) {
|
|
114
|
+
* const { DB_HOST, DB_PORT, DB_NAME } = config.unwrap();
|
|
115
|
+
* }
|
|
116
|
+
*
|
|
117
|
+
* // Listen for changes
|
|
118
|
+
* env.onSet((key, value) => {
|
|
119
|
+
* console.log(`${key} changed to ${value}`);
|
|
120
|
+
* }, 'API_KEY'); // Optional: filter by specific keys
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
66
123
|
export function envFactory(opts: Partial<EnvFactoryOpts> = {}): Env {
|
|
67
124
|
const found = envActions.find((fi) => fi.fn(opts).active());
|
|
68
125
|
if (!found) {
|
package/src/timeouted.ts
CHANGED
|
@@ -61,22 +61,58 @@ export interface TimeoutActionOptions<CTX> {
|
|
|
61
61
|
// TYPE GUARDS
|
|
62
62
|
// ============================================================================
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* Type guard to check if a TimeoutResult represents a successful completion.
|
|
66
|
+
*
|
|
67
|
+
* @template T - The type of the result value
|
|
68
|
+
* @param result - The TimeoutResult to check
|
|
69
|
+
* @returns True if the result state is "success"
|
|
70
|
+
*/
|
|
64
71
|
export function isSuccess<T>(result: TimeoutResult<T>): result is TimeoutResultSuccess<T> {
|
|
65
72
|
return result.state === "success";
|
|
66
73
|
}
|
|
67
74
|
|
|
75
|
+
/**
|
|
76
|
+
* Type guard to check if a TimeoutResult represents a timeout.
|
|
77
|
+
*
|
|
78
|
+
* @template T - The type of the result value
|
|
79
|
+
* @param result - The TimeoutResult to check
|
|
80
|
+
* @returns True if the result state is "timeout"
|
|
81
|
+
*/
|
|
68
82
|
export function isTimeout<T>(result: TimeoutResult<T>): result is TimeoutResultTimeout<T> {
|
|
69
83
|
return result.state === "timeout";
|
|
70
84
|
}
|
|
71
85
|
|
|
86
|
+
/**
|
|
87
|
+
* Type guard to check if a TimeoutResult was aborted via AbortSignal.
|
|
88
|
+
*
|
|
89
|
+
* @template T - The type of the result value
|
|
90
|
+
* @param result - The TimeoutResult to check
|
|
91
|
+
* @returns True if the result state is "aborted"
|
|
92
|
+
*/
|
|
72
93
|
export function isAborted<T>(result: TimeoutResult<T>): result is TimeoutResultAborted<T> {
|
|
73
94
|
return result.state === "aborted";
|
|
74
95
|
}
|
|
75
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Type guard to check if a TimeoutResult represents an error during execution.
|
|
99
|
+
*
|
|
100
|
+
* @template T - The type of the result value
|
|
101
|
+
* @param result - The TimeoutResult to check
|
|
102
|
+
* @returns True if the result state is "error"
|
|
103
|
+
*/
|
|
76
104
|
export function isError<T>(result: TimeoutResult<T>): result is TimeoutResultError<T> {
|
|
77
105
|
return result.state === "error";
|
|
78
106
|
}
|
|
79
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Extracts the value from a successful TimeoutResult or throws an error.
|
|
110
|
+
*
|
|
111
|
+
* @template T - The type of the result value
|
|
112
|
+
* @param result - The TimeoutResult to unwrap
|
|
113
|
+
* @returns The success value
|
|
114
|
+
* @throws Error if the result is not in success state
|
|
115
|
+
*/
|
|
80
116
|
export function unwrap<T>(result: TimeoutResult<T>): T {
|
|
81
117
|
if (isSuccess(result)) {
|
|
82
118
|
return result.value;
|
|
@@ -84,10 +120,66 @@ export function unwrap<T>(result: TimeoutResult<T>): T {
|
|
|
84
120
|
throw new Error(`TimeoutResult is not success: ${result.state}`);
|
|
85
121
|
}
|
|
86
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Extracts the value from a successful TimeoutResult or returns a default value.
|
|
125
|
+
*
|
|
126
|
+
* @template T - The type of the result value
|
|
127
|
+
* @param result - The TimeoutResult to unwrap
|
|
128
|
+
* @param defaultValue - The value to return if result is not successful
|
|
129
|
+
* @returns The success value or the default value
|
|
130
|
+
*/
|
|
87
131
|
export function unwrapOr<T>(result: TimeoutResult<T>, defaultValue: T): T {
|
|
88
132
|
return isSuccess(result) ? result.value : defaultValue;
|
|
89
133
|
}
|
|
90
134
|
|
|
135
|
+
/**
|
|
136
|
+
* Executes an action with comprehensive timeout and abort handling.
|
|
137
|
+
*
|
|
138
|
+
* Wraps a promise or async function with timeout, abort signal, and error handling capabilities.
|
|
139
|
+
* The action can be controlled via AbortController and will properly clean up resources.
|
|
140
|
+
*
|
|
141
|
+
* @template T - The type of the action's result value
|
|
142
|
+
* @template CTX - Optional context type passed through to callbacks
|
|
143
|
+
* @param action - Either a Promise or a function that receives an AbortController and returns a Promise
|
|
144
|
+
* @param options - Optional configuration:
|
|
145
|
+
* - timeout: Timeout duration in milliseconds (default: 30000). Set to 0 or negative to disable.
|
|
146
|
+
* - signal: External AbortSignal to link for cancellation
|
|
147
|
+
* - controller: External AbortController to use instead of creating a new one
|
|
148
|
+
* - ctx: Context object passed through in the result
|
|
149
|
+
* - onTimeout: Callback invoked when timeout occurs
|
|
150
|
+
* - onAbort: Callback invoked when aborted (with abort reason)
|
|
151
|
+
* - onError: Callback invoked when action throws an error
|
|
152
|
+
* - onAbortAction: Callback for cleanup when action needs to be aborted
|
|
153
|
+
*
|
|
154
|
+
* @returns Promise resolving to a TimeoutResult containing:
|
|
155
|
+
* - state: "success" | "timeout" | "aborted" | "error"
|
|
156
|
+
* - value (if success), error (if error), or reason (if aborted)
|
|
157
|
+
* - duration: Elapsed time in milliseconds
|
|
158
|
+
* - ctx: The context object if provided
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* // With a function that can be aborted
|
|
163
|
+
* const result = await timeouted(
|
|
164
|
+
* async (controller) => {
|
|
165
|
+
* return fetch(url, { signal: controller.signal });
|
|
166
|
+
* },
|
|
167
|
+
* { timeout: 5000 }
|
|
168
|
+
* );
|
|
169
|
+
*
|
|
170
|
+
* if (isSuccess(result)) {
|
|
171
|
+
* console.log('Request completed:', result.value);
|
|
172
|
+
* } else if (isTimeout(result)) {
|
|
173
|
+
* console.log('Request timed out after', result.duration, 'ms');
|
|
174
|
+
* }
|
|
175
|
+
*
|
|
176
|
+
* // With a direct promise
|
|
177
|
+
* const result2 = await timeouted(
|
|
178
|
+
* fetch(url),
|
|
179
|
+
* { timeout: 3000 }
|
|
180
|
+
* );
|
|
181
|
+
* ```
|
|
182
|
+
*/
|
|
91
183
|
export async function timeouted<T, CTX = void>(
|
|
92
184
|
action: TimeoutAction<T>,
|
|
93
185
|
options: Partial<TimeoutActionOptions<CTX>> = {},
|
package/src/tracer.ts
CHANGED
|
@@ -24,6 +24,24 @@ export type TraceCtxParam = {
|
|
|
24
24
|
}> &
|
|
25
25
|
Record<string, unknown>;
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Represents a single metric value that can be tracked and accumulated.
|
|
29
|
+
*
|
|
30
|
+
* Metrics can store any type of value and support addition operations
|
|
31
|
+
* for numbers and arrays. Used within the tracing system to collect
|
|
32
|
+
* performance data and custom measurements.
|
|
33
|
+
*
|
|
34
|
+
* @template T - The type of the metric value
|
|
35
|
+
*
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const counter = new Metric<number>('/api/requests');
|
|
39
|
+
* counter.set(0);
|
|
40
|
+
* counter.add(1);
|
|
41
|
+
* counter.add(5);
|
|
42
|
+
* console.log(counter.value); // 6
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
27
45
|
export class Metric<T> {
|
|
28
46
|
value?: T;
|
|
29
47
|
readonly path: string;
|
|
@@ -55,6 +73,29 @@ export class Metric<T> {
|
|
|
55
73
|
|
|
56
74
|
export type MetricMap = Map<string, Metric<unknown>>;
|
|
57
75
|
|
|
76
|
+
/**
|
|
77
|
+
* Container for managing multiple metrics within a trace span.
|
|
78
|
+
*
|
|
79
|
+
* Metrics provides hierarchical metric management with path-based access.
|
|
80
|
+
* Metrics can be defined at absolute paths (starting with /) or relative
|
|
81
|
+
* to the current trace span. Supports JSON serialization of all metrics.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const metrics = new Metrics(traceNode);
|
|
86
|
+
*
|
|
87
|
+
* // Absolute path
|
|
88
|
+
* const totalRequests = metrics.get<number>('/api/total_requests');
|
|
89
|
+
* totalRequests.set(100);
|
|
90
|
+
*
|
|
91
|
+
* // Relative path (uses trace node's root path)
|
|
92
|
+
* const spanRequests = metrics.get<number>('requests');
|
|
93
|
+
* spanRequests.add(1);
|
|
94
|
+
*
|
|
95
|
+
* // Export as JSON
|
|
96
|
+
* const data = metrics.toJSON();
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
58
99
|
export class Metrics {
|
|
59
100
|
readonly tracenode: TraceNode;
|
|
60
101
|
private readonly map: MetricMap;
|
package/src/txt-en-decoder.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Lazy } from "./resolve-once.js";
|
|
2
2
|
import { Result } from "./result.js";
|
|
3
3
|
import { coerceIntoUint8, ToUInt8 } from "./utils/coerce-uint8.js";
|
|
4
4
|
|
|
@@ -50,7 +50,4 @@ class TxtOps implements TxtEnDecoder {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
const
|
|
54
|
-
export function TxtEnDecoderSingleton(): TxtEnDecoder {
|
|
55
|
-
return txtEnDecoder.once(() => new TxtOps());
|
|
56
|
-
}
|
|
53
|
+
export const TxtEnDecoderSingleton: () => TxtEnDecoder = Lazy((): TxtEnDecoder => new TxtOps());
|
package/src/uri.ts
CHANGED
|
@@ -16,9 +16,6 @@ export interface IsURIResult {
|
|
|
16
16
|
readonly uri?: URI;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
/** @xdeprecated use param from get-params-result */
|
|
20
|
-
// export const key = param;
|
|
21
|
-
|
|
22
19
|
/*
|
|
23
20
|
if KeyParam is a Object
|
|
24
21
|
if the right side is a string, it is the default value
|
|
@@ -172,6 +169,24 @@ function ensureURLWithDefaultProto<T>(
|
|
|
172
169
|
}
|
|
173
170
|
}
|
|
174
171
|
|
|
172
|
+
/**
|
|
173
|
+
* Type guard to check if a value is a URL object.
|
|
174
|
+
*
|
|
175
|
+
* Checks both for instanceof URL and for objects with URL-like properties
|
|
176
|
+
* (searchParams object with sort method, hash string), allowing it to work
|
|
177
|
+
* with URL objects from different execution contexts.
|
|
178
|
+
*
|
|
179
|
+
* @param value - The value to check
|
|
180
|
+
* @returns True if the value is a URL or URL-like object
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* ```typescript
|
|
184
|
+
* const value: unknown = new URL('https://example.com');
|
|
185
|
+
* if (isURL(value)) {
|
|
186
|
+
* console.log(value.hostname); // "example.com"
|
|
187
|
+
* }
|
|
188
|
+
* ```
|
|
189
|
+
*/
|
|
175
190
|
export function isURL(value: unknown): value is URL {
|
|
176
191
|
return (
|
|
177
192
|
value instanceof URL ||
|
|
@@ -263,6 +278,31 @@ function setParams(
|
|
|
263
278
|
return out.toString();
|
|
264
279
|
}
|
|
265
280
|
|
|
281
|
+
/**
|
|
282
|
+
* Mutable builder for constructing and manipulating URIs.
|
|
283
|
+
*
|
|
284
|
+
* BuildURI provides a fluent API for constructing URIs by chaining method calls.
|
|
285
|
+
* Unlike URI, BuildURI is mutable and allows modification of all URI components
|
|
286
|
+
* (protocol, hostname, port, pathname, search params, hash).
|
|
287
|
+
*
|
|
288
|
+
* @example
|
|
289
|
+
* ```typescript
|
|
290
|
+
* const uri = BuildURI.from('https://example.com')
|
|
291
|
+
* .pathname('/api/users')
|
|
292
|
+
* .setParam('page', '1')
|
|
293
|
+
* .setParam('limit', '10')
|
|
294
|
+
* .toString();
|
|
295
|
+
* // Result: "https://example.com/api/users?limit=10&page=1"
|
|
296
|
+
*
|
|
297
|
+
* // Building from scratch
|
|
298
|
+
* const uri2 = BuildURI.from()
|
|
299
|
+
* .protocol('https')
|
|
300
|
+
* .hostname('api.example.com')
|
|
301
|
+
* .port('8080')
|
|
302
|
+
* .pathname('/v1/data')
|
|
303
|
+
* .URI(); // Convert to immutable URI
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
266
306
|
export class BuildURI implements URIInterface<BuildURI> {
|
|
267
307
|
_url: WritableURL; // pathname needs this
|
|
268
308
|
private constructor(url: WritableURL) {
|
|
@@ -493,7 +533,39 @@ export const hasHostPartProtocols: Set<string> = new Set<string>(["http", "https
|
|
|
493
533
|
const uriInstances = new KeyedResolvOnce<URI>({
|
|
494
534
|
lru: { maxEntries: 1000 },
|
|
495
535
|
});
|
|
496
|
-
|
|
536
|
+
|
|
537
|
+
/**
|
|
538
|
+
* Immutable URI representation with type-safe parameter handling.
|
|
539
|
+
*
|
|
540
|
+
* URI provides a read-only view of a URL with convenient methods for accessing
|
|
541
|
+
* components and query parameters. All URI instances are cached for performance.
|
|
542
|
+
* Use BuildURI for mutable construction and URI for immutable references.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* const uri = URI.from('https://example.com/path?key=value&foo=bar');
|
|
547
|
+
*
|
|
548
|
+
* // Access components
|
|
549
|
+
* console.log(uri.protocol); // "https:"
|
|
550
|
+
* console.log(uri.hostname); // "example.com"
|
|
551
|
+
* console.log(uri.pathname); // "/path"
|
|
552
|
+
*
|
|
553
|
+
* // Query parameters
|
|
554
|
+
* const key = uri.getParam('key'); // "value"
|
|
555
|
+
* const missing = uri.getParam('missing', 'default'); // "default"
|
|
556
|
+
*
|
|
557
|
+
* // Type-safe parameter extraction with Result
|
|
558
|
+
* const result = uri.getParamsResult('key', 'foo');
|
|
559
|
+
* if (result.isOk()) {
|
|
560
|
+
* const { key, foo } = result.unwrap();
|
|
561
|
+
* }
|
|
562
|
+
*
|
|
563
|
+
* // Build a modified version
|
|
564
|
+
* const modified = uri.build()
|
|
565
|
+
* .setParam('new', 'param')
|
|
566
|
+
* .URI();
|
|
567
|
+
* ```
|
|
568
|
+
*/
|
|
497
569
|
export class URI implements URIInterface<URI> {
|
|
498
570
|
static protocolHasHostpart(protocol: string): () => void {
|
|
499
571
|
protocol = protocol.replace(/:$/, "");
|
|
@@ -18,6 +18,37 @@ export type ToUInt8Async = ToUInt8Plain | Blob;
|
|
|
18
18
|
export type ToUInt8 = ToUInt8Plain | Result<ToUInt8Plain>;
|
|
19
19
|
export type AsyncToUInt8 = ToUInt8Async | Result<ToUInt8Async> | Promise<ToUInt8Async> | Promise<Result<ToUInt8Async>>;
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Coerces various binary types into Uint8Array with Result-based error handling.
|
|
23
|
+
*
|
|
24
|
+
* Converts ArrayBuffer, ArrayBufferView, Node.js Buffer, or Result-wrapped values
|
|
25
|
+
* into Uint8Array. Returns Result.Err for unsupported types like Blob (use
|
|
26
|
+
* asyncCoerceIntoUint8 for Blobs). Handles Result-wrapped inputs by unwrapping
|
|
27
|
+
* and recursively coercing.
|
|
28
|
+
*
|
|
29
|
+
* @param raw - Binary data to coerce (ArrayBuffer, TypedArray, Buffer, or Result-wrapped)
|
|
30
|
+
* @returns Result.Ok with Uint8Array or Result.Err with error message
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // ArrayBuffer
|
|
35
|
+
* const result1 = coerceIntoUint8(new ArrayBuffer(10));
|
|
36
|
+
* if (result1.isOk()) {
|
|
37
|
+
* const bytes = result1.unwrap(); // Uint8Array
|
|
38
|
+
* }
|
|
39
|
+
*
|
|
40
|
+
* // TypedArray
|
|
41
|
+
* const result2 = coerceIntoUint8(new Int32Array([1, 2, 3]));
|
|
42
|
+
*
|
|
43
|
+
* // Result-wrapped input
|
|
44
|
+
* const wrapped = Result.Ok(new ArrayBuffer(5));
|
|
45
|
+
* const result3 = coerceIntoUint8(wrapped); // Unwraps and converts
|
|
46
|
+
*
|
|
47
|
+
* // Blob not supported (use asyncCoerceIntoUint8)
|
|
48
|
+
* const result4 = coerceIntoUint8(new Blob(['data']));
|
|
49
|
+
* // Returns Result.Err("Blob not supported")
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
21
52
|
export function coerceIntoUint8(raw: ToUInt8): Result<Uint8Array> {
|
|
22
53
|
if (raw instanceof ArrayBuffer) {
|
|
23
54
|
return Result.Ok(new Uint8Array(raw));
|
|
@@ -43,6 +74,35 @@ export function coerceIntoUint8(raw: ToUInt8): Result<Uint8Array> {
|
|
|
43
74
|
return Result.Err("Not a Uint8Array");
|
|
44
75
|
}
|
|
45
76
|
|
|
77
|
+
/**
|
|
78
|
+
* Asynchronously coerces various binary types including Blob into Uint8Array.
|
|
79
|
+
*
|
|
80
|
+
* Handles all types supported by coerceIntoUint8 plus async operations:
|
|
81
|
+
* - Promise-wrapped values
|
|
82
|
+
* - Blob (converts via arrayBuffer())
|
|
83
|
+
* - Result-wrapped Promises
|
|
84
|
+
*
|
|
85
|
+
* @param raw - Binary data or Promise thereof (including Blob)
|
|
86
|
+
* @returns Promise resolving to Result.Ok with Uint8Array or Result.Err
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* // Blob support
|
|
91
|
+
* const blob = new Blob(['Hello, World!']);
|
|
92
|
+
* const result1 = await asyncCoerceIntoUint8(blob);
|
|
93
|
+
* if (result1.isOk()) {
|
|
94
|
+
* const bytes = result1.unwrap();
|
|
95
|
+
* }
|
|
96
|
+
*
|
|
97
|
+
* // Promise-wrapped
|
|
98
|
+
* const promise = fetch('/data').then(r => r.arrayBuffer());
|
|
99
|
+
* const result2 = await asyncCoerceIntoUint8(promise);
|
|
100
|
+
*
|
|
101
|
+
* // Result-wrapped Promise
|
|
102
|
+
* const wrapped = Promise.resolve(Result.Ok(new ArrayBuffer(10)));
|
|
103
|
+
* const result3 = await asyncCoerceIntoUint8(wrapped);
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
46
106
|
export async function asyncCoerceIntoUint8(raw: AsyncToUInt8): Promise<Result<Uint8Array>> {
|
|
47
107
|
let resolved = await raw;
|
|
48
108
|
if (resolved instanceof Blob) {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import { TxtEnDecoderSingleton } from "../txt-en-decoder.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* WritableStreamDefaultWriter that writes to console with automatic JSON parsing.
|
|
5
|
+
*
|
|
6
|
+
* Decodes Uint8Array chunks to strings, attempts JSON parsing to extract log levels,
|
|
7
|
+
* and routes output to appropriate console methods (log, warn, error).
|
|
8
|
+
*/
|
|
3
9
|
export class ConsoleWriterStreamDefaultWriter implements WritableStreamDefaultWriter<Uint8Array> {
|
|
4
10
|
readonly desiredSize: number | null = null;
|
|
5
11
|
// readonly decoder: TextDecoder = new TextDecoder();
|
|
@@ -57,6 +63,34 @@ export interface ConsoleWriterStreamParams {
|
|
|
57
63
|
warn(...args: unknown[]): void;
|
|
58
64
|
}
|
|
59
65
|
|
|
66
|
+
/**
|
|
67
|
+
* WritableStream that outputs to console with JSON log-level parsing.
|
|
68
|
+
*
|
|
69
|
+
* Decodes stream chunks and attempts to parse as JSON to extract log levels.
|
|
70
|
+
* Routes messages to console.log/warn/error based on parsed level field.
|
|
71
|
+
* Falls back to console.log for non-JSON content. Useful for structured logging.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const consoleStream = new ConsoleWriterStream();
|
|
76
|
+
* const writer = consoleStream.getWriter();
|
|
77
|
+
*
|
|
78
|
+
* // JSON with level field
|
|
79
|
+
* await writer.write(
|
|
80
|
+
* new TextEncoder().encode('{"level":"error","msg":"Failed"}')
|
|
81
|
+
* ); // Outputs to console.error
|
|
82
|
+
*
|
|
83
|
+
* // Plain text
|
|
84
|
+
* await writer.write(
|
|
85
|
+
* new TextEncoder().encode('Hello')
|
|
86
|
+
* ); // Outputs to console.log
|
|
87
|
+
*
|
|
88
|
+
* // Custom console methods
|
|
89
|
+
* const custom = new ConsoleWriterStream({
|
|
90
|
+
* error: (msg) => saveToFile('error.log', msg)
|
|
91
|
+
* });
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
60
94
|
export class ConsoleWriterStream implements WritableStream<Uint8Array> {
|
|
61
95
|
locked = false;
|
|
62
96
|
_writer?: WritableStreamDefaultWriter<Uint8Array>;
|