@wener/utils 1.1.51 → 1.1.54
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/lib/arrays/MaybeArray.js +58 -8
- package/lib/arrays/arrayFromAsync.js +254 -6
- package/lib/asyncs/AsyncInterval.js +145 -9
- package/lib/asyncs/MaybePromise.js +0 -2
- package/lib/asyncs/Promises.js +95 -48
- package/lib/asyncs/createAsyncIterator.js +313 -23
- package/lib/asyncs/createLazyPromise.js +72 -31
- package/lib/asyncs/createLazyPromise.test.js +367 -0
- package/lib/asyncs/firstOfAsyncIterator.js +6 -6
- package/lib/asyncs/generatorOfStream.js +125 -14
- package/lib/asyncs/isIterator.js +1 -3
- package/lib/asyncs/isPromise.js +2 -4
- package/lib/asyncs/isThenable.js +0 -2
- package/lib/asyncs/nextOfAsyncIterator.js +15 -9
- package/lib/asyncs/promiseOfCallback.js +2 -4
- package/lib/asyncs/timeout.js +122 -13
- package/lib/browsers/copy.js +7 -8
- package/lib/browsers/download.js +215 -40
- package/lib/browsers/getFileFromDataTransfer.js +17 -14
- package/lib/browsers/loaders.js +251 -18
- package/lib/crypto/base.js +3 -3
- package/lib/crypto/getNodeCrypto.js +3 -5
- package/lib/crypto/hashing.js +236 -30
- package/lib/crypto/hashing.test.js +323 -0
- package/lib/crypto/md5.bench.js +11 -11
- package/lib/crypto/md5.d.js +0 -2
- package/lib/crypto/md5.js +0 -2
- package/lib/crypto/md5.test.js +7 -0
- package/lib/crypto/pem/pem.js +197 -35
- package/lib/crypto/pem/pem.test.js +104 -0
- package/lib/crypto/randomUUIDv7.js +0 -2
- package/lib/crypto/ulid.js +84 -48
- package/lib/crypto/ulid.test.js +115 -0
- package/lib/emitter/types.js +0 -2
- package/lib/errors/DetailError.js +297 -0
- package/lib/errors/Errors.js +136 -137
- package/lib/errors/Errors.test.js +24 -0
- package/lib/fetch/HttpStatus.js +1 -3
- package/lib/fetch/createFetchWith.js +188 -19
- package/lib/fetch/createFetchWithLogging.js +17 -16
- package/lib/fetch/createFetchWithRetry.js +40 -24
- package/lib/fetch/dumpRequest.js +467 -41
- package/lib/fetch/dumpRequest.test.js +384 -0
- package/lib/fetch/dumpResponse.js +271 -16
- package/lib/fetch/dumpResponse.test.js +393 -0
- package/lib/fetch/http.types.js +0 -2
- package/lib/fetch/index.js +5 -7
- package/lib/fetch/isTextContentType.js +5 -0
- package/lib/fetch/resolveRequest.js +7 -0
- package/lib/fetch/types.js +0 -2
- package/lib/i18n/createTranslate.js +40 -20
- package/lib/i18n/createTranslate.test.js +177 -0
- package/lib/index.js +75 -76
- package/lib/io/AbstractEncoding.js +0 -2
- package/lib/io/ArrayBuffer.test-d.js +4 -6
- package/lib/io/ArrayBuffers.base64.test.js +60 -0
- package/lib/io/ArrayBuffers.js +396 -171
- package/lib/io/ArrayBuffers.test.js +77 -0
- package/lib/io/Buffer.js +190 -20
- package/lib/io/Buffer.test.js +22 -0
- package/lib/io/ByteBuffer.js +752 -441
- package/lib/io/ByteBuffer.test.js +184 -0
- package/lib/io/base64.js +17 -19
- package/lib/io/dump.js +16 -16
- package/lib/io/isBuffer.js +2 -3
- package/lib/io/isBuffer.test.js +8 -0
- package/lib/io/isTransferable.js +16 -8
- package/lib/io/isTransferable.test.js +17 -0
- package/lib/io/parseDataUri.js +288 -40
- package/lib/io/parseDataUri.test.js +286 -0
- package/lib/io/types.js +1 -0
- package/lib/langs/AsyncCloser.js +270 -34
- package/lib/langs/Closer.js +95 -29
- package/lib/langs/MaybeFunction.js +38 -5
- package/lib/langs/classOf.js +0 -2
- package/lib/langs/deepEqual.js +82 -22
- package/lib/langs/deepEqual.test.js +11 -0
- package/lib/langs/deepFreeze.js +28 -9
- package/lib/langs/getGlobalStates.js +14 -10
- package/lib/langs/getObjectId.js +4 -6
- package/lib/langs/ifPresent.js +0 -2
- package/lib/langs/isClass.js +0 -2
- package/lib/langs/isDefined.js +0 -2
- package/lib/langs/isEmptyObject.js +1 -3
- package/lib/langs/isFunction.js +0 -2
- package/lib/langs/isNil.js +3 -0
- package/lib/langs/isPlainObject.js +2 -4
- package/lib/langs/langs.test.js +126 -0
- package/lib/langs/memoize.js +11 -7
- package/lib/langs/mixin.js +7 -4
- package/lib/langs/mixin.test.js +135 -0
- package/lib/langs/parseBoolean.js +11 -8
- package/lib/langs/parseDate.js +20 -0
- package/lib/langs/shallowClone.js +5 -3
- package/lib/langs/shallowEqual.js +8 -6
- package/lib/libs/ms.js +28 -26
- package/lib/libs/ms.test.js +301 -0
- package/lib/logger/const.js +15 -0
- package/lib/logger/index.js +1 -0
- package/lib/logger/types.js +1 -0
- package/lib/maths/clamp.js +81 -12
- package/lib/maths/clamp.test.js +186 -0
- package/lib/maths/createRandom.test.js +36 -0
- package/lib/maths/random.js +162 -13
- package/lib/modules/isModule.js +0 -2
- package/lib/modules/parseModuleId.js +14 -15
- package/lib/modules/parseModuleId.test.js +153 -0
- package/lib/objects/computeIfAbsent.js +8 -3
- package/lib/objects/get.js +26 -8
- package/lib/objects/get.test-d.js +23 -25
- package/lib/objects/merge/index.js +1 -3
- package/lib/objects/merge/isMergeableObject.js +5 -3
- package/lib/objects/merge/merge.js +82 -26
- package/lib/objects/merge/merge.test.js +1397 -0
- package/lib/objects/parseObjectPath.js +47 -15
- package/lib/objects/parseObjectPath.test.js +138 -0
- package/lib/objects/set.js +25 -19
- package/lib/objects/set.test.js +522 -0
- package/lib/schema/typebox/index.js +2 -3
- package/lib/schema/typebox/typebox.js +6 -6
- package/lib/scripts/getGenerateContext.js +386 -77
- package/lib/server/crypto/md5.js +0 -2
- package/lib/server/fetch/createFetchWithProxy.js +2 -4
- package/lib/server/fetch/createFetchWithProxyByNodeFetch.js +258 -31
- package/lib/server/fetch/createFetchWithProxyByUndici.js +307 -49
- package/lib/server/getPackageDir.js +2 -3
- package/lib/server/index.js +5 -7
- package/lib/server/jsdom.js +1 -3
- package/lib/server/node-fetch.js +2 -4
- package/lib/server/polyfill/polyfillBrowser.js +163 -9
- package/lib/server/polyfill/polyfillBrowser.test.js +164 -0
- package/lib/server/polyfill/polyfillCrypto.js +157 -9
- package/lib/server/polyfill/polyfillFetch.js +13 -13
- package/lib/server/polyfill/polyfillJsDom.js +264 -58
- package/lib/server/polyfill/polyfillWebSocket.js +11 -11
- package/lib/server/ws.js +1 -3
- package/lib/strings/bytes.test.js +327 -0
- package/lib/strings/camelCase.js +23 -14
- package/lib/strings/formatBytes.js +29 -20
- package/lib/strings/parseBytes.js +54 -0
- package/lib/strings/renderTemplate.js +17 -12
- package/lib/strings/renderTemplate.test.js +104 -0
- package/lib/typedoc.js +2 -4
- package/lib/types.d.js +0 -2
- package/lib/validations/asserts.js +0 -2
- package/lib/validations/isUUID.js +0 -2
- package/lib/validations/isUUID.test.js +87 -0
- package/lib/validations/parseTimestamp.js +12 -7
- package/lib/validations/parseTimestamp.test.js +6 -0
- package/lib/web/getGlobalThis.js +3 -4
- package/lib/web/getRandomValues.js +28 -20
- package/lib/web/randomUUID.js +7 -8
- package/lib/web/requestIdleCallback.js +13 -9
- package/lib/web/structuredClone.js +35 -28
- package/lib/web/structuredClone.test.js +81 -0
- package/package.json +9 -14
- package/src/arrays/MaybeArray.ts +22 -22
- package/src/arrays/arrayFromAsync.ts +3 -3
- package/src/asyncs/AsyncInterval.ts +8 -8
- package/src/asyncs/Promises.ts +51 -51
- package/src/asyncs/createAsyncIterator.ts +33 -33
- package/src/asyncs/createLazyPromise.test.ts +73 -73
- package/src/asyncs/createLazyPromise.ts +68 -73
- package/src/asyncs/firstOfAsyncIterator.ts +5 -5
- package/src/asyncs/generatorOfStream.ts +12 -12
- package/src/asyncs/isIterator.ts +1 -1
- package/src/asyncs/isThenable.ts +2 -2
- package/src/asyncs/nextOfAsyncIterator.ts +20 -20
- package/src/asyncs/promiseOfCallback.ts +13 -13
- package/src/asyncs/timeout.ts +23 -23
- package/src/browsers/copy.ts +48 -48
- package/src/browsers/download.ts +38 -36
- package/src/browsers/getFileFromDataTransfer.ts +35 -35
- package/src/browsers/loaders.ts +49 -49
- package/src/crypto/base.ts +3 -3
- package/src/crypto/getNodeCrypto.ts +2 -2
- package/src/crypto/hashing.test.ts +33 -47
- package/src/crypto/hashing.ts +67 -67
- package/src/crypto/md5.bench.ts +20 -24
- package/src/crypto/md5.test.ts +3 -3
- package/src/crypto/pem/pem.test.ts +26 -42
- package/src/crypto/pem/pem.ts +65 -65
- package/src/crypto/ulid.test.ts +31 -31
- package/src/crypto/ulid.ts +116 -116
- package/src/emitter/types.ts +6 -6
- package/src/errors/DetailError.ts +151 -0
- package/src/errors/Errors.test.ts +15 -15
- package/src/errors/Errors.ts +97 -238
- package/src/fetch/HttpStatus.ts +77 -77
- package/src/fetch/createFetchWith.ts +25 -25
- package/src/fetch/createFetchWithLogging.ts +12 -15
- package/src/fetch/createFetchWithRetry.ts +79 -79
- package/src/fetch/dumpRequest.test.ts +176 -0
- package/src/fetch/dumpRequest.ts +149 -52
- package/src/fetch/dumpResponse.test.ts +160 -0
- package/src/fetch/dumpResponse.ts +48 -20
- package/src/fetch/http.types.ts +35 -35
- package/src/fetch/isTextContentType.ts +12 -0
- package/src/fetch/resolveRequest.ts +1 -0
- package/src/fetch/types.ts +2 -2
- package/src/i18n/createTranslate.test.ts +90 -113
- package/src/i18n/createTranslate.ts +55 -55
- package/src/index.ts +26 -26
- package/src/io/AbstractEncoding.ts +12 -12
- package/src/io/ArrayBuffer.test-d.ts +1 -1
- package/src/io/ArrayBuffers.base64.test.ts +52 -52
- package/src/io/ArrayBuffers.test.ts +14 -14
- package/src/io/ArrayBuffers.ts +645 -415
- package/src/io/Buffer.test.ts +17 -17
- package/src/io/Buffer.ts +17 -17
- package/src/io/ByteBuffer.test.ts +37 -37
- package/src/io/ByteBuffer.ts +574 -566
- package/src/io/base64.ts +46 -44
- package/src/io/dump.ts +22 -22
- package/src/io/isBuffer.test.ts +2 -2
- package/src/io/isBuffer.ts +1 -1
- package/src/io/isTransferable.test.ts +4 -4
- package/src/io/isTransferable.ts +29 -29
- package/src/io/parseDataUri.test.ts +22 -27
- package/src/io/parseDataUri.ts +57 -57
- package/src/io/types.ts +13 -0
- package/src/langs/AsyncCloser.ts +34 -34
- package/src/langs/Closer.ts +28 -28
- package/src/langs/MaybeFunction.ts +5 -5
- package/src/langs/classOf.ts +1 -1
- package/src/langs/deepEqual.test.ts +1 -12
- package/src/langs/deepEqual.ts +82 -82
- package/src/langs/deepFreeze.ts +11 -11
- package/src/langs/getGlobalStates.ts +16 -16
- package/src/langs/getObjectId.ts +10 -13
- package/src/langs/ifPresent.ts +2 -2
- package/src/langs/isClass.ts +1 -1
- package/src/langs/isDefined.ts +1 -1
- package/src/langs/isEmptyObject.ts +1 -1
- package/src/langs/isFunction.ts +1 -1
- package/src/langs/isNil.ts +3 -0
- package/src/langs/isPlainObject.ts +4 -4
- package/src/langs/langs.test.ts +18 -18
- package/src/langs/memoize.ts +21 -21
- package/src/langs/mixin.test.ts +22 -26
- package/src/langs/mixin.ts +6 -9
- package/src/langs/parseBoolean.ts +30 -26
- package/src/langs/parseDate.ts +13 -0
- package/src/langs/shallowClone.ts +11 -11
- package/src/langs/shallowEqual.ts +19 -19
- package/src/libs/ms.test.ts +274 -274
- package/src/libs/ms.ts +137 -137
- package/src/logger/const.ts +18 -0
- package/src/logger/index.ts +2 -0
- package/src/logger/types.ts +10 -0
- package/src/maths/clamp.test.ts +18 -18
- package/src/maths/clamp.ts +17 -17
- package/src/maths/createRandom.test.ts +12 -0
- package/src/maths/random.ts +50 -14
- package/src/modules/isModule.ts +4 -4
- package/src/modules/parseModuleId.test.ts +61 -68
- package/src/modules/parseModuleId.ts +29 -43
- package/src/objects/computeIfAbsent.ts +10 -10
- package/src/objects/get.test-d.ts +33 -51
- package/src/objects/get.ts +31 -31
- package/src/objects/merge/isMergeableObject.ts +5 -5
- package/src/objects/merge/merge.test.ts +658 -880
- package/src/objects/merge/merge.ts +84 -84
- package/src/objects/parseObjectPath.test.ts +13 -13
- package/src/objects/parseObjectPath.ts +25 -25
- package/src/objects/set.test.ts +271 -366
- package/src/objects/set.ts +36 -36
- package/src/schema/typebox/typebox.ts +20 -26
- package/src/scripts/getGenerateContext.ts +79 -79
- package/src/server/crypto/md5.ts +1 -1
- package/src/server/fetch/createFetchWithProxyByNodeFetch.ts +28 -31
- package/src/server/fetch/createFetchWithProxyByUndici.ts +63 -69
- package/src/server/getPackageDir.ts +7 -7
- package/src/server/polyfill/polyfillBrowser.test.ts +10 -10
- package/src/server/polyfill/polyfillBrowser.ts +3 -3
- package/src/server/polyfill/polyfillCrypto.ts +6 -6
- package/src/server/polyfill/polyfillFetch.ts +11 -21
- package/src/server/polyfill/polyfillJsDom.ts +59 -71
- package/src/server/polyfill/polyfillWebSocket.ts +14 -14
- package/src/strings/bytes.test.ts +69 -0
- package/src/strings/camelCase.ts +58 -63
- package/src/strings/formatBytes.ts +50 -29
- package/src/strings/parseBytes.ts +66 -0
- package/src/strings/renderTemplate.test.ts +10 -17
- package/src/strings/renderTemplate.ts +19 -22
- package/src/types.d.ts +9 -9
- package/src/validations/asserts.ts +8 -8
- package/src/validations/isUUID.test.ts +8 -8
- package/src/validations/isUUID.ts +1 -1
- package/src/validations/parseTimestamp.test.ts +2 -2
- package/src/validations/parseTimestamp.ts +21 -21
- package/src/web/getGlobalThis.ts +6 -6
- package/src/web/getRandomValues.ts +29 -29
- package/src/web/randomUUID.ts +5 -5
- package/src/web/requestIdleCallback.ts +7 -10
- package/src/web/structuredClone.test.ts +8 -8
- package/src/web/structuredClone.ts +62 -62
- package/tsconfig.json +26 -34
- package/lib/arrays/MaybeArray.js.map +0 -1
- package/lib/arrays/arrayFromAsync.js.map +0 -1
- package/lib/asyncs/AsyncInterval.js.map +0 -1
- package/lib/asyncs/MaybePromise.js.map +0 -1
- package/lib/asyncs/Promises.js.map +0 -1
- package/lib/asyncs/createAsyncIterator.js.map +0 -1
- package/lib/asyncs/createLazyPromise.js.map +0 -1
- package/lib/asyncs/firstOfAsyncIterator.js.map +0 -1
- package/lib/asyncs/generatorOfStream.js.map +0 -1
- package/lib/asyncs/isIterator.js.map +0 -1
- package/lib/asyncs/isPromise.js.map +0 -1
- package/lib/asyncs/isThenable.js.map +0 -1
- package/lib/asyncs/nextOfAsyncIterator.js.map +0 -1
- package/lib/asyncs/promiseOfCallback.js.map +0 -1
- package/lib/asyncs/timeout.js.map +0 -1
- package/lib/browsers/copy.js.map +0 -1
- package/lib/browsers/download.js.map +0 -1
- package/lib/browsers/getFileFromDataTransfer.js.map +0 -1
- package/lib/browsers/loaders.js.map +0 -1
- package/lib/cn/division/DivisionCode.js +0 -215
- package/lib/cn/division/DivisionCode.js.map +0 -1
- package/lib/cn/division/binarySearch.js +0 -27
- package/lib/cn/division/binarySearch.js.map +0 -1
- package/lib/cn/formatChineseAmount.js +0 -77
- package/lib/cn/formatChineseAmount.js.map +0 -1
- package/lib/cn/id/Mod11.js +0 -43
- package/lib/cn/id/Mod11.js.map +0 -1
- package/lib/cn/id/ResidentIdNumber.js +0 -98
- package/lib/cn/id/ResidentIdNumber.js.map +0 -1
- package/lib/cn/id/types.js +0 -8
- package/lib/cn/id/types.js.map +0 -1
- package/lib/cn/index.js +0 -14
- package/lib/cn/index.js.map +0 -1
- package/lib/cn/parseChineseNumber.js +0 -94
- package/lib/cn/parseChineseNumber.js.map +0 -1
- package/lib/cn/pinyin/cartesianProduct.js +0 -22
- package/lib/cn/pinyin/cartesianProduct.js.map +0 -1
- package/lib/cn/pinyin/data.json +0 -413
- package/lib/cn/pinyin/loader.js +0 -15
- package/lib/cn/pinyin/loader.js.map +0 -1
- package/lib/cn/pinyin/preload.js +0 -4
- package/lib/cn/pinyin/preload.js.map +0 -1
- package/lib/cn/pinyin/toPinyinPure.js +0 -32
- package/lib/cn/pinyin/toPinyinPure.js.map +0 -1
- package/lib/cn/pinyin/transform.js +0 -14
- package/lib/cn/pinyin/transform.js.map +0 -1
- package/lib/cn/types.js +0 -3
- package/lib/cn/types.js.map +0 -1
- package/lib/cn/uscc/Mod31.js +0 -49
- package/lib/cn/uscc/Mod31.js.map +0 -1
- package/lib/cn/uscc/USCC.js +0 -94
- package/lib/cn/uscc/USCC.js.map +0 -1
- package/lib/cn/uscc/isUSCC.js +0 -8
- package/lib/cn/uscc/isUSCC.js.map +0 -1
- package/lib/crypto/base.js.map +0 -1
- package/lib/crypto/getNodeCrypto.js.map +0 -1
- package/lib/crypto/hashing.js.map +0 -1
- package/lib/crypto/md5.bench.js.map +0 -1
- package/lib/crypto/md5.d.js.map +0 -1
- package/lib/crypto/md5.js.map +0 -1
- package/lib/crypto/pem/pem.js.map +0 -1
- package/lib/crypto/randomUUIDv7.js.map +0 -1
- package/lib/crypto/ulid.js.map +0 -1
- package/lib/emitter/types.js.map +0 -1
- package/lib/errors/Errors.js.map +0 -1
- package/lib/fetch/HttpStatus.js.map +0 -1
- package/lib/fetch/createFetchWith.js.map +0 -1
- package/lib/fetch/createFetchWithLogging.js.map +0 -1
- package/lib/fetch/createFetchWithRetry.js.map +0 -1
- package/lib/fetch/dumpRequest.js.map +0 -1
- package/lib/fetch/dumpResponse.js.map +0 -1
- package/lib/fetch/http.types.js.map +0 -1
- package/lib/fetch/index.js.map +0 -1
- package/lib/fetch/types.js.map +0 -1
- package/lib/i18n/createTranslate.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/io/AbstractEncoding.js.map +0 -1
- package/lib/io/ArrayBuffer.test-d.js.map +0 -1
- package/lib/io/ArrayBuffers.js.map +0 -1
- package/lib/io/Buffer.js.map +0 -1
- package/lib/io/ByteBuffer.js.map +0 -1
- package/lib/io/base64.js.map +0 -1
- package/lib/io/dump.js.map +0 -1
- package/lib/io/isBuffer.js.map +0 -1
- package/lib/io/isTransferable.js.map +0 -1
- package/lib/io/parseDataUri.js.map +0 -1
- package/lib/langs/AsyncCloser.js.map +0 -1
- package/lib/langs/Closer.js.map +0 -1
- package/lib/langs/MaybeFunction.js.map +0 -1
- package/lib/langs/classOf.js.map +0 -1
- package/lib/langs/deepEqual.js.map +0 -1
- package/lib/langs/deepFreeze.js.map +0 -1
- package/lib/langs/getGlobalStates.js.map +0 -1
- package/lib/langs/getObjectId.js.map +0 -1
- package/lib/langs/ifPresent.js.map +0 -1
- package/lib/langs/isClass.js.map +0 -1
- package/lib/langs/isDefined.js.map +0 -1
- package/lib/langs/isEmptyObject.js.map +0 -1
- package/lib/langs/isFunction.js.map +0 -1
- package/lib/langs/isNullish.js +0 -5
- package/lib/langs/isNullish.js.map +0 -1
- package/lib/langs/isPlainObject.js.map +0 -1
- package/lib/langs/memoize.js.map +0 -1
- package/lib/langs/mixin.js.map +0 -1
- package/lib/langs/parseBoolean.js.map +0 -1
- package/lib/langs/shallowClone.js.map +0 -1
- package/lib/langs/shallowEqual.js.map +0 -1
- package/lib/libs/ms.js.map +0 -1
- package/lib/logging/Logger.js +0 -5
- package/lib/logging/Logger.js.map +0 -1
- package/lib/logging/createChildLogger.js +0 -16
- package/lib/logging/createChildLogger.js.map +0 -1
- package/lib/logging/createLogger.js +0 -63
- package/lib/logging/createLogger.js.map +0 -1
- package/lib/logging/createNoopLogger.js +0 -13
- package/lib/logging/createNoopLogger.js.map +0 -1
- package/lib/logging/slog.js +0 -143
- package/lib/logging/slog.js.map +0 -1
- package/lib/maths/clamp.js.map +0 -1
- package/lib/maths/random.js.map +0 -1
- package/lib/mitt/index.js +0 -77
- package/lib/mitt/index.js.map +0 -1
- package/lib/modules/isModule.js.map +0 -1
- package/lib/modules/parseModuleId.js.map +0 -1
- package/lib/objects/computeIfAbsent.js.map +0 -1
- package/lib/objects/get.js.map +0 -1
- package/lib/objects/get.test-d.js.map +0 -1
- package/lib/objects/merge/index.js.map +0 -1
- package/lib/objects/merge/isMergeableObject.js.map +0 -1
- package/lib/objects/merge/merge.js.map +0 -1
- package/lib/objects/parseObjectPath.js.map +0 -1
- package/lib/objects/set.js.map +0 -1
- package/lib/schema/typebox/index.js.map +0 -1
- package/lib/schema/typebox/typebox.js.map +0 -1
- package/lib/scripts/getGenerateContext.js.map +0 -1
- package/lib/server/crypto/md5.js.map +0 -1
- package/lib/server/fetch/createFetchWithProxy.js.map +0 -1
- package/lib/server/fetch/createFetchWithProxyByNodeFetch.js.map +0 -1
- package/lib/server/fetch/createFetchWithProxyByUndici.js.map +0 -1
- package/lib/server/getPackageDir.js.map +0 -1
- package/lib/server/index.js.map +0 -1
- package/lib/server/jsdom.js.map +0 -1
- package/lib/server/node-fetch.js.map +0 -1
- package/lib/server/polyfill/polyfillBrowser.js.map +0 -1
- package/lib/server/polyfill/polyfillCrypto.js.map +0 -1
- package/lib/server/polyfill/polyfillFetch.js.map +0 -1
- package/lib/server/polyfill/polyfillJsDom.js.map +0 -1
- package/lib/server/polyfill/polyfillWebSocket.js.map +0 -1
- package/lib/server/ws.js.map +0 -1
- package/lib/strings/camelCase.js.map +0 -1
- package/lib/strings/formatBytes.js.map +0 -1
- package/lib/strings/renderTemplate.js.map +0 -1
- package/lib/typedoc.js.map +0 -1
- package/lib/types.d.js.map +0 -1
- package/lib/validations/asserts.js.map +0 -1
- package/lib/validations/isUUID.js.map +0 -1
- package/lib/validations/parseTimestamp.js.map +0 -1
- package/lib/web/getGlobalThis.js.map +0 -1
- package/lib/web/getRandomValues.js.map +0 -1
- package/lib/web/randomUUID.js.map +0 -1
- package/lib/web/requestIdleCallback.js.map +0 -1
- package/lib/web/structuredClone.js.map +0 -1
- package/src/cn/README.md +0 -3
- package/src/cn/division/DivisionCode.ts +0 -173
- package/src/cn/division/binarySearch.test.ts +0 -64
- package/src/cn/division/binarySearch.ts +0 -25
- package/src/cn/division/division.test.ts +0 -22
- package/src/cn/formatChineseAmount.ts +0 -61
- package/src/cn/id/Mod11.ts +0 -26
- package/src/cn/id/ResidentIdNumber.ts +0 -126
- package/src/cn/id/id.test.ts +0 -20
- package/src/cn/id/types.ts +0 -26
- package/src/cn/index.ts +0 -17
- package/src/cn/parseChineseNumber.test.ts +0 -159
- package/src/cn/parseChineseNumber.ts +0 -97
- package/src/cn/pinyin/cartesianProduct.test.ts +0 -64
- package/src/cn/pinyin/cartesianProduct.ts +0 -24
- package/src/cn/pinyin/data.json +0 -413
- package/src/cn/pinyin/loader.ts +0 -12
- package/src/cn/pinyin/preload.ts +0 -3
- package/src/cn/pinyin/toPinyin.test.ts +0 -12
- package/src/cn/pinyin/toPinyinPure.ts +0 -43
- package/src/cn/pinyin/transform.ts +0 -12
- package/src/cn/scripts/gen.test.ts +0 -131
- package/src/cn/types.ts +0 -11
- package/src/cn/uscc/Mod31.ts +0 -38
- package/src/cn/uscc/USCC.ts +0 -94
- package/src/cn/uscc/isUSCC.ts +0 -8
- package/src/cn/uscc/uscc.test.ts +0 -16
- package/src/langs/isNullish.ts +0 -3
- package/src/logging/Logger.ts +0 -25
- package/src/logging/createChildLogger.ts +0 -16
- package/src/logging/createLogger.ts +0 -50
- package/src/logging/createNoopLogger.ts +0 -13
- package/src/logging/logger.test.ts +0 -36
- package/src/logging/slog.test.ts +0 -8
- package/src/logging/slog.ts +0 -221
- package/src/mitt/README.md +0 -1
- package/src/mitt/index.ts +0 -114
package/src/fetch/dumpRequest.ts
CHANGED
|
@@ -1,55 +1,152 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { isTextContentType } from './isTextContentType';
|
|
2
|
+
|
|
3
|
+
export async function dumpRequest({
|
|
4
|
+
url,
|
|
5
|
+
req,
|
|
6
|
+
method,
|
|
7
|
+
body,
|
|
8
|
+
log = console.log,
|
|
9
|
+
dumpBody: shouldDumpBody = true,
|
|
5
10
|
}: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
url?: string;
|
|
12
|
+
req?: RequestInit;
|
|
13
|
+
method?: string;
|
|
14
|
+
body?: any;
|
|
15
|
+
log?: (s: string) => void;
|
|
16
|
+
dumpBody?: boolean;
|
|
9
17
|
}) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
18
|
+
const parts = ['->'];
|
|
19
|
+
const requestMethod = method || req?.method;
|
|
20
|
+
if (requestMethod) {
|
|
21
|
+
parts.push(requestMethod);
|
|
22
|
+
}
|
|
23
|
+
if (url) {
|
|
24
|
+
parts.push(url);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
let out = `${parts.join(' ')}
|
|
28
|
+
${Array.from(new Headers(req?.headers).entries())
|
|
29
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
30
|
+
.join('\n')}
|
|
31
|
+
`;
|
|
32
|
+
|
|
33
|
+
const shouldTee = !body;
|
|
34
|
+
body ??= req?.body;
|
|
35
|
+
if (shouldDumpBody && body) {
|
|
36
|
+
const contentType = new Headers(req?.headers).get('content-type') || '';
|
|
37
|
+
|
|
38
|
+
if (shouldTee && req?.body instanceof ReadableStream) {
|
|
39
|
+
const [previewStream, originalStream] = req.body.tee();
|
|
40
|
+
req.body = originalStream;
|
|
41
|
+
body = previewStream;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
out += await dumpBodyContent({ body, contentType, canPreviewStream: shouldTee });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
log(out);
|
|
48
|
+
return out;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export async function dumpBodyContent({
|
|
52
|
+
body,
|
|
53
|
+
contentType,
|
|
54
|
+
canPreviewStream = true,
|
|
55
|
+
}: {
|
|
56
|
+
body?: any;
|
|
57
|
+
contentType?: string;
|
|
58
|
+
canPreviewStream?: boolean;
|
|
59
|
+
}): Promise<string> {
|
|
60
|
+
if (!body) return '';
|
|
61
|
+
|
|
62
|
+
if (contentType === 'application/octet-stream') {
|
|
63
|
+
return `\n[Binary content not displayed: ${contentType}]\n`;
|
|
64
|
+
} else if (body instanceof ReadableStream) {
|
|
65
|
+
if (!canPreviewStream) {
|
|
66
|
+
return `\n[ReadableStream - cannot preview external stream]\n`;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Try to preview ReadableStream content safely
|
|
70
|
+
try {
|
|
71
|
+
const reader = body.getReader();
|
|
72
|
+
let previewedBytes = 0;
|
|
73
|
+
const maxPreviewSize = 1024; // 1KB preview limit
|
|
74
|
+
let previewContent = '';
|
|
75
|
+
let wasTruncated = false;
|
|
76
|
+
|
|
77
|
+
while (previewedBytes < maxPreviewSize) {
|
|
78
|
+
const { done, value } = await reader.read();
|
|
79
|
+
if (done) break;
|
|
80
|
+
|
|
81
|
+
if (value instanceof Uint8Array) {
|
|
82
|
+
// Check if adding this chunk would exceed the limit
|
|
83
|
+
if (previewedBytes + value.length > maxPreviewSize) {
|
|
84
|
+
const remainingBytes = maxPreviewSize - previewedBytes;
|
|
85
|
+
const truncatedValue = value.slice(0, remainingBytes);
|
|
86
|
+
const decoded = new TextDecoder('utf-8', { fatal: false }).decode(truncatedValue);
|
|
87
|
+
previewContent += decoded;
|
|
88
|
+
wasTruncated = true;
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
const decoded = new TextDecoder('utf-8', { fatal: false }).decode(value);
|
|
93
|
+
previewContent += decoded;
|
|
94
|
+
previewedBytes += value.length;
|
|
95
|
+
} else {
|
|
96
|
+
const strValue = String(value);
|
|
97
|
+
if (previewedBytes + strValue.length > maxPreviewSize) {
|
|
98
|
+
const remainingChars = maxPreviewSize - previewedBytes;
|
|
99
|
+
previewContent += strValue.slice(0, remainingChars);
|
|
100
|
+
wasTruncated = true;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
previewContent += strValue;
|
|
105
|
+
previewedBytes += strValue.length;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// If we exited the loop without hitting done, we were truncated
|
|
110
|
+
if (!wasTruncated && previewedBytes >= maxPreviewSize) {
|
|
111
|
+
wasTruncated = true;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
let result = `\n${previewContent}`;
|
|
115
|
+
if (wasTruncated) {
|
|
116
|
+
result += `\n[... truncated]\n`;
|
|
117
|
+
} else {
|
|
118
|
+
result += `\n`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
reader.releaseLock();
|
|
122
|
+
return result;
|
|
123
|
+
} catch (error) {
|
|
124
|
+
return `\n[Error reading stream: ${error}]\n`;
|
|
125
|
+
}
|
|
126
|
+
} else if (body instanceof FormData) {
|
|
127
|
+
let result = `\n[FormData content]\n`;
|
|
128
|
+
try {
|
|
129
|
+
for (const [key, value] of body.entries()) {
|
|
130
|
+
if (typeof value === 'string') {
|
|
131
|
+
result += `${key}: ${value}\n`;
|
|
132
|
+
} else {
|
|
133
|
+
result += `${key}: [File: ${value.name || 'unknown'}]\n`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
return result;
|
|
137
|
+
} catch (error) {
|
|
138
|
+
return result + `[Error reading FormData: ${error}]\n`;
|
|
139
|
+
}
|
|
140
|
+
} else if (body instanceof URLSearchParams) {
|
|
141
|
+
return `\n${body.toString()}\n`;
|
|
142
|
+
} else if (isTextContentType(contentType || '') || typeof body === 'string') {
|
|
143
|
+
try {
|
|
144
|
+
const bodyContent = typeof body === 'string' ? body : String(body);
|
|
145
|
+
return `\n${bodyContent}\n`;
|
|
146
|
+
} catch (error) {
|
|
147
|
+
return `\n[Error reading request body: ${error}]\n`;
|
|
148
|
+
}
|
|
149
|
+
} else {
|
|
150
|
+
return `\n[Non-text content: ${typeof body}]\n`;
|
|
151
|
+
}
|
|
55
152
|
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { dumpResponse } from './dumpResponse';
|
|
3
|
+
|
|
4
|
+
describe('dumpResponse', () => {
|
|
5
|
+
const NETWORK_TIMEOUT = 15000;
|
|
6
|
+
|
|
7
|
+
it(
|
|
8
|
+
'should dump JSON response with all parameters',
|
|
9
|
+
async () => {
|
|
10
|
+
const logSpy = vi.fn();
|
|
11
|
+
|
|
12
|
+
const response = await fetch('https://httpbin.org/json');
|
|
13
|
+
const result = await dumpResponse({
|
|
14
|
+
res: response,
|
|
15
|
+
url: 'https://httpbin.org/json',
|
|
16
|
+
method: 'GET',
|
|
17
|
+
log: logSpy,
|
|
18
|
+
dumpBody: true,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
expect(logSpy).toHaveBeenCalledOnce();
|
|
22
|
+
const loggedOutput = logSpy.mock.calls[0][0];
|
|
23
|
+
|
|
24
|
+
// Check basic format
|
|
25
|
+
expect(loggedOutput).toContain('<- 200 OK GET https://httpbin.org/json');
|
|
26
|
+
expect(loggedOutput).toContain('content-type: application/json');
|
|
27
|
+
expect(loggedOutput).toContain('slideshow');
|
|
28
|
+
|
|
29
|
+
// Should return original response
|
|
30
|
+
expect(result).toBe(response);
|
|
31
|
+
},
|
|
32
|
+
NETWORK_TIMEOUT,
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
it(
|
|
36
|
+
'should work with minimal parameters',
|
|
37
|
+
async () => {
|
|
38
|
+
const logSpy = vi.fn();
|
|
39
|
+
|
|
40
|
+
const response = await fetch('https://httpbin.org/status/204');
|
|
41
|
+
await dumpResponse({
|
|
42
|
+
res: response,
|
|
43
|
+
log: logSpy,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const loggedOutput = logSpy.mock.calls[0][0];
|
|
47
|
+
|
|
48
|
+
// Should only show status without method/url (HTTPBin uses uppercase)
|
|
49
|
+
expect(loggedOutput).toContain('<- 204');
|
|
50
|
+
expect(loggedOutput).not.toContain('GET');
|
|
51
|
+
expect(loggedOutput).not.toContain('https://');
|
|
52
|
+
},
|
|
53
|
+
NETWORK_TIMEOUT,
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
it('should handle binary content', async () => {
|
|
57
|
+
const logSpy = vi.fn();
|
|
58
|
+
|
|
59
|
+
// Create a mock response with binary content
|
|
60
|
+
const response = new Response(new Uint8Array([1, 2, 3]), {
|
|
61
|
+
status: 200,
|
|
62
|
+
statusText: 'OK',
|
|
63
|
+
headers: { 'content-type': 'application/octet-stream' },
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
await dumpResponse({
|
|
67
|
+
res: response,
|
|
68
|
+
url: 'https://example.com/binary',
|
|
69
|
+
method: 'GET',
|
|
70
|
+
log: logSpy,
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const loggedOutput = logSpy.mock.calls[0][0];
|
|
74
|
+
|
|
75
|
+
expect(loggedOutput).toContain('<- 200 OK GET https://example.com/binary');
|
|
76
|
+
expect(loggedOutput).toContain('[Binary content not displayed: application/octet-stream]');
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it(
|
|
80
|
+
'should preserve original response after dumping',
|
|
81
|
+
async () => {
|
|
82
|
+
const response = await fetch('https://httpbin.org/json');
|
|
83
|
+
|
|
84
|
+
const result = await dumpResponse({
|
|
85
|
+
res: response,
|
|
86
|
+
dumpBody: true,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// Original response should still be readable
|
|
90
|
+
const data = await result.json();
|
|
91
|
+
expect(data.slideshow).toBeDefined();
|
|
92
|
+
},
|
|
93
|
+
NETWORK_TIMEOUT,
|
|
94
|
+
);
|
|
95
|
+
|
|
96
|
+
it('should handle dumpBody false with mock response', async () => {
|
|
97
|
+
const logSpy = vi.fn();
|
|
98
|
+
|
|
99
|
+
const response = new Response('{"test": true}', {
|
|
100
|
+
status: 200,
|
|
101
|
+
statusText: 'OK',
|
|
102
|
+
headers: { 'content-type': 'application/json' },
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
await dumpResponse({
|
|
106
|
+
res: response,
|
|
107
|
+
url: 'https://example.com/test',
|
|
108
|
+
method: 'POST',
|
|
109
|
+
log: logSpy,
|
|
110
|
+
dumpBody: false,
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
const loggedOutput = logSpy.mock.calls[0][0];
|
|
114
|
+
|
|
115
|
+
// Should not contain body content
|
|
116
|
+
expect(loggedOutput).toContain('<- 200 OK POST https://example.com/test');
|
|
117
|
+
expect(loggedOutput).toContain('content-type: application/json');
|
|
118
|
+
expect(loggedOutput).not.toContain('{"test": true}');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it('should handle req.method fallback', async () => {
|
|
122
|
+
const logSpy = vi.fn();
|
|
123
|
+
|
|
124
|
+
const response = new Response('success', {
|
|
125
|
+
status: 200,
|
|
126
|
+
statusText: 'OK',
|
|
127
|
+
headers: { 'content-type': 'text/plain' },
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
await dumpResponse({
|
|
131
|
+
res: response,
|
|
132
|
+
req: { method: 'PUT' },
|
|
133
|
+
url: 'https://example.com/test',
|
|
134
|
+
log: logSpy,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const loggedOutput = logSpy.mock.calls[0][0];
|
|
138
|
+
expect(loggedOutput).toContain('<- 200 OK PUT https://example.com/test');
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
it('should handle method parameter override', async () => {
|
|
142
|
+
const logSpy = vi.fn();
|
|
143
|
+
|
|
144
|
+
const response = new Response('success', {
|
|
145
|
+
status: 201,
|
|
146
|
+
statusText: 'Created',
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
await dumpResponse({
|
|
150
|
+
res: response,
|
|
151
|
+
req: { method: 'POST' },
|
|
152
|
+
method: 'PATCH', // should override req.method
|
|
153
|
+
url: 'https://example.com/test',
|
|
154
|
+
log: logSpy,
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const loggedOutput = logSpy.mock.calls[0][0];
|
|
158
|
+
expect(loggedOutput).toContain('<- 201 Created PATCH https://example.com/test');
|
|
159
|
+
});
|
|
160
|
+
});
|
|
@@ -1,28 +1,56 @@
|
|
|
1
|
+
import { isTextContentType } from './isTextContentType';
|
|
2
|
+
|
|
1
3
|
export async function dumpResponse({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
res,
|
|
5
|
+
url,
|
|
6
|
+
req,
|
|
7
|
+
method,
|
|
8
|
+
log = console.log,
|
|
9
|
+
dumpBody = true,
|
|
10
|
+
clone = dumpBody,
|
|
6
11
|
}: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
12
|
+
res: Response;
|
|
13
|
+
url?: string;
|
|
14
|
+
req?: RequestInit;
|
|
15
|
+
method?: string;
|
|
16
|
+
log?: (s: string) => void;
|
|
17
|
+
dumpBody?: boolean;
|
|
18
|
+
clone?: boolean;
|
|
11
19
|
}) {
|
|
12
|
-
|
|
20
|
+
const shouldClone = clone || dumpBody;
|
|
21
|
+
const responseToProcess = shouldClone ? res.clone() : res;
|
|
22
|
+
|
|
23
|
+
const parts = [`<- ${res.status} ${res.statusText}`];
|
|
24
|
+
const requestMethod = method || req?.method;
|
|
25
|
+
if (requestMethod) {
|
|
26
|
+
parts.push(requestMethod);
|
|
27
|
+
}
|
|
28
|
+
if (url) {
|
|
29
|
+
parts.push(url);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let out = `${parts.join(' ')}
|
|
13
33
|
${Array.from(res.headers.entries())
|
|
14
|
-
|
|
15
|
-
|
|
34
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
35
|
+
.join('\n')}
|
|
16
36
|
`;
|
|
17
|
-
let contentType = res.headers.get('content-type');
|
|
18
|
-
// TODO text/event-stream
|
|
19
|
-
if (contentType?.includes('application/json') || contentType?.includes('text/plain')) {
|
|
20
|
-
const body = await res.text();
|
|
21
|
-
out += `\n${body}\n`;
|
|
22
|
-
res = new Response(body, res);
|
|
23
|
-
}
|
|
24
37
|
|
|
25
|
-
|
|
38
|
+
if (dumpBody) {
|
|
39
|
+
const ct = res.headers.get('content-type') || '';
|
|
40
|
+
|
|
41
|
+
if (isTextContentType(ct)) {
|
|
42
|
+
try {
|
|
43
|
+
const responseBody = await responseToProcess.text();
|
|
44
|
+
out += `\n${responseBody}\n`;
|
|
45
|
+
} catch (error) {
|
|
46
|
+
out += `\n[Error reading response body: ${error}]\n`;
|
|
47
|
+
}
|
|
48
|
+
} else {
|
|
49
|
+
out += `\n[Binary content not displayed: ${ct}]\n`;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
log(out);
|
|
26
54
|
|
|
27
|
-
|
|
55
|
+
return res;
|
|
28
56
|
}
|
package/src/fetch/http.types.ts
CHANGED
|
@@ -5,42 +5,42 @@ export type SuccessStatusCode = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 |
|
|
|
5
5
|
export type DeprecatedStatusCode = 305 | 306;
|
|
6
6
|
export type RedirectStatusCode = 300 | 301 | 302 | 303 | 304 | DeprecatedStatusCode | 307 | 308;
|
|
7
7
|
export type ClientErrorStatusCode =
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
8
|
+
| 400
|
|
9
|
+
| 401
|
|
10
|
+
| 402
|
|
11
|
+
| 403
|
|
12
|
+
| 404
|
|
13
|
+
| 405
|
|
14
|
+
| 406
|
|
15
|
+
| 407
|
|
16
|
+
| 408
|
|
17
|
+
| 409
|
|
18
|
+
| 410
|
|
19
|
+
| 411
|
|
20
|
+
| 412
|
|
21
|
+
| 413
|
|
22
|
+
| 414
|
|
23
|
+
| 415
|
|
24
|
+
| 416
|
|
25
|
+
| 417
|
|
26
|
+
| 418
|
|
27
|
+
| 421
|
|
28
|
+
| 422
|
|
29
|
+
| 423
|
|
30
|
+
| 424
|
|
31
|
+
| 425
|
|
32
|
+
| 426
|
|
33
|
+
| 428
|
|
34
|
+
| 429
|
|
35
|
+
| 431
|
|
36
|
+
| 451;
|
|
37
37
|
export type ServerErrorStatusCode = 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 510 | 511;
|
|
38
38
|
|
|
39
39
|
export type UnofficialStatusCode = -1;
|
|
40
40
|
export type StatusCode =
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
| InfoStatusCode
|
|
42
|
+
| SuccessStatusCode
|
|
43
|
+
| RedirectStatusCode
|
|
44
|
+
| ClientErrorStatusCode
|
|
45
|
+
| ServerErrorStatusCode
|
|
46
|
+
| UnofficialStatusCode;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the content type represents text content that can be safely displayed
|
|
3
|
+
*/
|
|
4
|
+
export function isTextContentType(contentType: string): boolean {
|
|
5
|
+
return (
|
|
6
|
+
contentType.includes('application/json')
|
|
7
|
+
|| contentType.includes('text/')
|
|
8
|
+
|| contentType.includes('application/xml')
|
|
9
|
+
|| contentType.includes('application/javascript')
|
|
10
|
+
|| contentType.includes('application/x-www-form-urlencoded')
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function resolveRequest({}: {}) {}
|
package/src/fetch/types.ts
CHANGED