@wener/utils 1.1.27 → 1.1.29
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 +36 -25
- package/lib/arrays/MaybeArray.js.map +1 -1
- package/lib/arrays/arrayFromAsync.js +5 -7
- package/lib/arrays/arrayFromAsync.js.map +1 -1
- package/lib/asyncs/AsyncInterval.js +11 -12
- package/lib/asyncs/AsyncInterval.js.map +1 -1
- package/lib/asyncs/MaybePromise.js +3 -0
- package/lib/asyncs/MaybePromise.js.map +1 -0
- package/lib/asyncs/createAsyncIterator.js +37 -35
- package/lib/asyncs/createAsyncIterator.js.map +1 -1
- package/lib/asyncs/createLazyPromise.js +59 -60
- package/lib/asyncs/createLazyPromise.js.map +1 -1
- package/lib/asyncs/firstOfAsyncIterator.js +7 -9
- package/lib/asyncs/firstOfAsyncIterator.js.map +1 -1
- package/lib/asyncs/generatorOfStream.js +16 -0
- package/lib/asyncs/generatorOfStream.js.map +1 -0
- package/lib/asyncs/isIterator.js +3 -4
- package/lib/asyncs/isIterator.js.map +1 -1
- package/lib/asyncs/isPromise.js +3 -4
- package/lib/asyncs/isPromise.js.map +1 -1
- package/lib/asyncs/isThenable.js +6 -0
- package/lib/asyncs/isThenable.js.map +1 -0
- package/lib/asyncs/nextOfAsyncIterator.js +20 -14
- package/lib/asyncs/nextOfAsyncIterator.js.map +1 -1
- package/lib/asyncs/promiseOfCallback.js +17 -0
- package/lib/asyncs/promiseOfCallback.js.map +1 -0
- package/lib/asyncs/sleep.js +2 -3
- package/lib/asyncs/sleep.js.map +1 -1
- package/lib/asyncs/timeout.js +22 -26
- package/lib/asyncs/timeout.js.map +1 -1
- package/lib/browsers/copy.js +47 -45
- package/lib/browsers/copy.js.map +1 -1
- package/lib/browsers/download.js +38 -27
- package/lib/browsers/download.js.map +1 -1
- package/lib/browsers/getFileFromDataTransfer.js +41 -28
- package/lib/browsers/getFileFromDataTransfer.js.map +1 -1
- package/lib/browsers/loaders.js +43 -43
- package/lib/browsers/loaders.js.map +1 -1
- package/lib/crypto/base.js +5 -4
- package/lib/crypto/base.js.map +1 -1
- package/lib/crypto/getNodeCrypto.js +14 -13
- package/lib/crypto/getNodeCrypto.js.map +1 -1
- package/lib/crypto/getRandomValues.js +22 -26
- package/lib/crypto/getRandomValues.js.map +1 -1
- package/lib/crypto/hashing.js +42 -50
- package/lib/crypto/hashing.js.map +1 -1
- package/lib/crypto/md5.bench.js +21 -0
- package/lib/crypto/md5.bench.js.map +1 -0
- package/lib/crypto/md5.d.js +3 -0
- package/lib/crypto/md5.d.js.map +1 -0
- package/lib/crypto/md5.js +119 -121
- package/lib/crypto/md5.js.map +1 -1
- package/lib/crypto/pem/pem.js +32 -35
- package/lib/crypto/pem/pem.js.map +1 -1
- package/lib/crypto/randomUUID.js +12 -11
- package/lib/crypto/randomUUID.js.map +1 -1
- package/lib/crypto/ulid.js +123 -112
- package/lib/crypto/ulid.js.map +1 -1
- package/lib/errors/Errors.js +167 -149
- package/lib/errors/Errors.js.map +1 -1
- package/lib/fetch/createFetchWith.js +20 -23
- package/lib/fetch/createFetchWith.js.map +1 -1
- package/lib/fetch/createFetchWithLogging.js +20 -16
- package/lib/fetch/createFetchWithLogging.js.map +1 -1
- package/lib/fetch/createFetchWithRetry.js +61 -65
- package/lib/fetch/createFetchWithRetry.js.map +1 -1
- package/lib/fetch/dumpRequest.js +39 -42
- package/lib/fetch/dumpRequest.js.map +1 -1
- package/lib/fetch/dumpResponse.js +13 -20
- package/lib/fetch/dumpResponse.js.map +1 -1
- package/lib/fetch/index.js +7 -0
- package/lib/fetch/index.js.map +1 -0
- package/lib/fetch/types.js +3 -0
- package/lib/fetch/types.js.map +1 -0
- package/lib/http/HttpStatus.js +89 -80
- package/lib/http/HttpStatus.js.map +1 -1
- package/lib/i18n/createTranslate.js +48 -48
- package/lib/i18n/createTranslate.js.map +1 -1
- package/lib/index.js +28 -14
- package/lib/index.js.map +1 -1
- package/lib/io/AbstractEncoding.js +7 -0
- package/lib/io/AbstractEncoding.js.map +1 -0
- package/lib/io/ArrayBuffer.test-d.js +7 -0
- package/lib/io/ArrayBuffer.test-d.js.map +1 -0
- package/lib/io/ArrayBuffers.js +198 -172
- package/lib/io/ArrayBuffers.js.map +1 -1
- package/lib/io/Buffer.js +21 -20
- package/lib/io/Buffer.js.map +1 -1
- package/lib/io/base64.js +49 -48
- package/lib/io/base64.js.map +1 -1
- package/lib/io/isBuffer.js +7 -5
- package/lib/io/isBuffer.js.map +1 -1
- package/lib/io/isTransferable.js +23 -19
- package/lib/io/isTransferable.js.map +1 -1
- package/lib/isomorphics/getGlobalThis.js +17 -12
- package/lib/isomorphics/getGlobalThis.js.map +1 -1
- package/lib/isomorphics/structuredClone.js +71 -63
- package/lib/isomorphics/structuredClone.js.map +1 -1
- package/lib/langs/MaybeFunction.js +7 -7
- package/lib/langs/MaybeFunction.js.map +1 -1
- package/lib/langs/classOf.js +3 -4
- package/lib/langs/classOf.js.map +1 -1
- package/lib/langs/deepEqual.js +77 -85
- package/lib/langs/deepEqual.js.map +1 -1
- package/lib/langs/deepFreeze.js +17 -13
- package/lib/langs/deepFreeze.js.map +1 -1
- package/lib/langs/hashCode.ignored.js +112 -0
- package/lib/langs/hashCode.ignored.js.map +1 -0
- package/lib/langs/isClass.js +3 -4
- package/lib/langs/isClass.js.map +1 -1
- package/lib/langs/isDefined.js +3 -4
- package/lib/langs/isDefined.js.map +1 -1
- package/lib/langs/isEmptyObject.js +3 -5
- package/lib/langs/isEmptyObject.js.map +1 -1
- package/lib/langs/isFunction.js +5 -0
- package/lib/langs/isFunction.js.map +1 -0
- package/lib/langs/isPlainObject.js +7 -8
- package/lib/langs/isPlainObject.js.map +1 -1
- package/lib/langs/memoize.js +19 -21
- package/lib/langs/memoize.js.map +1 -1
- package/lib/langs/parseBoolean.js +26 -27
- package/lib/langs/parseBoolean.js.map +1 -1
- package/lib/langs/shallowClone.js +12 -12
- package/lib/langs/shallowClone.js.map +1 -1
- package/lib/langs/shallowEqual.js +21 -18
- package/lib/langs/shallowEqual.js.map +1 -1
- package/lib/libs/ms.js +123 -103
- package/lib/libs/ms.js.map +1 -1
- package/lib/logging/Logger.js +5 -0
- package/lib/logging/Logger.js.map +1 -0
- package/lib/logging/createChildLogger.js +12 -14
- package/lib/logging/createChildLogger.js.map +1 -1
- package/lib/logging/createLogger.js +59 -33
- package/lib/logging/createLogger.js.map +1 -1
- package/lib/logging/createNoopLogger.js +11 -12
- package/lib/logging/createNoopLogger.js.map +1 -1
- package/lib/logging/slog.js +143 -0
- package/lib/logging/slog.js.map +1 -0
- package/lib/maths/clamp.js +20 -20
- package/lib/maths/clamp.js.map +1 -1
- package/lib/maths/random.js +14 -15
- package/lib/maths/random.js.map +1 -1
- package/lib/modules/isModule.js +5 -4
- package/lib/modules/isModule.js.map +1 -1
- package/lib/modules/parseModuleId.js +36 -31
- package/lib/modules/parseModuleId.js.map +1 -1
- package/lib/objects/get.js +13 -11
- package/lib/objects/get.js.map +1 -1
- package/lib/objects/get.test-d.js +33 -0
- package/lib/objects/get.test-d.js.map +1 -0
- package/lib/objects/merge/index.js +3 -0
- package/lib/objects/merge/index.js.map +1 -0
- package/lib/objects/merge/isMergeableObject.js +11 -10
- package/lib/objects/merge/isMergeableObject.js.map +1 -1
- package/lib/objects/merge/merge.js +65 -66
- package/lib/objects/merge/merge.js.map +1 -1
- package/lib/objects/parseObjectPath.js +35 -23
- package/lib/objects/parseObjectPath.js.map +1 -1
- package/lib/objects/set.js +33 -34
- package/lib/objects/set.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/common/encoder.js +93 -67
- package/lib/schema/typebox/gen/codegen/common/encoder.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/common/formatter.js +31 -8
- package/lib/schema/typebox/gen/codegen/common/formatter.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/common/index.js +5 -0
- package/lib/schema/typebox/gen/codegen/common/index.js.map +1 -0
- package/lib/schema/typebox/gen/codegen/common/jsdoc.js +109 -60
- package/lib/schema/typebox/gen/codegen/common/jsdoc.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/expression/compiler.js +359 -317
- package/lib/schema/typebox/gen/codegen/expression/compiler.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/expression/errors.js +255 -233
- package/lib/schema/typebox/gen/codegen/expression/errors.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/expression/evaluator.js +249 -236
- package/lib/schema/typebox/gen/codegen/expression/evaluator.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/expression/expression.js +382 -198
- package/lib/schema/typebox/gen/codegen/expression/expression.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/expression/index.js +6 -0
- package/lib/schema/typebox/gen/codegen/expression/index.js.map +1 -0
- package/lib/schema/typebox/gen/codegen/index.js +5 -19
- package/lib/schema/typebox/gen/codegen/index.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/index.js +16 -0
- package/lib/schema/typebox/gen/codegen/model/index.js.map +1 -0
- package/lib/schema/typebox/gen/codegen/model/model-to-arktype.js +236 -260
- package/lib/schema/typebox/gen/codegen/model/model-to-arktype.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-expression.js +348 -352
- package/lib/schema/typebox/gen/codegen/model/model-to-expression.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-grpc.js +214 -242
- package/lib/schema/typebox/gen/codegen/model/model-to-grpc.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-io-ts.js +229 -292
- package/lib/schema/typebox/gen/codegen/model/model-to-io-ts.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-javascript.js +42 -15
- package/lib/schema/typebox/gen/codegen/model/model-to-javascript.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-json-schema.js +168 -168
- package/lib/schema/typebox/gen/codegen/model/model-to-json-schema.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-typebox.js +31 -8
- package/lib/schema/typebox/gen/codegen/model/model-to-typebox.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-typescript.js +156 -190
- package/lib/schema/typebox/gen/codegen/model/model-to-typescript.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-valibot.js +215 -249
- package/lib/schema/typebox/gen/codegen/model/model-to-valibot.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-value.js +37 -13
- package/lib/schema/typebox/gen/codegen/model/model-to-value.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-yrel.js +201 -242
- package/lib/schema/typebox/gen/codegen/model/model-to-yrel.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-yup.js +200 -245
- package/lib/schema/typebox/gen/codegen/model/model-to-yup.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model-to-zod.js +223 -268
- package/lib/schema/typebox/gen/codegen/model/model-to-zod.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/model/model.js +27 -0
- package/lib/schema/typebox/gen/codegen/model/model.js.map +1 -0
- package/lib/schema/typebox/gen/codegen/typescript/index.js +4 -0
- package/lib/schema/typebox/gen/codegen/typescript/index.js.map +1 -0
- package/lib/schema/typebox/gen/codegen/typescript/typescript-to-model.js +43 -40
- package/lib/schema/typebox/gen/codegen/typescript/typescript-to-model.js.map +1 -1
- package/lib/schema/typebox/gen/codegen/typescript/typescript-to-typebox.js +592 -616
- package/lib/schema/typebox/gen/codegen/typescript/typescript-to-typebox.js.map +1 -1
- package/lib/schema/typebox/gen/index.js +3 -3
- package/lib/schema/typebox/gen/index.js.map +1 -1
- package/lib/schema/typebox/index.js +3 -3
- package/lib/schema/typebox/index.js.map +1 -1
- package/lib/schema/typebox/typebox.js +18 -29
- package/lib/schema/typebox/typebox.js.map +1 -1
- package/lib/server.js +2 -1
- package/lib/server.js.map +1 -1
- package/lib/servers/crypto/md5.js +3 -5
- package/lib/servers/crypto/md5.js.map +1 -1
- package/lib/servers/fetch/createFetchWithProxy.js +2 -4
- package/lib/servers/fetch/createFetchWithProxy.js.map +1 -1
- package/lib/servers/fetch/createFetchWithProxyByNodeFetch.js +34 -34
- package/lib/servers/fetch/createFetchWithProxyByNodeFetch.js.map +1 -1
- package/lib/servers/fetch/createFetchWithProxyByUndici.js +57 -58
- package/lib/servers/fetch/createFetchWithProxyByUndici.js.map +1 -1
- package/lib/servers/getPackageDir.js +8 -10
- package/lib/servers/getPackageDir.js.map +1 -1
- package/lib/servers/jsdom.js +3 -2
- package/lib/servers/jsdom.js.map +1 -1
- package/lib/servers/node-fetch.js +4 -3
- package/lib/servers/node-fetch.js.map +1 -1
- package/lib/servers/polyfill/polyfillBrowser.js +17 -0
- package/lib/servers/polyfill/polyfillBrowser.js.map +1 -0
- package/lib/servers/polyfill/polyfillCrypto.js +8 -10
- package/lib/servers/polyfill/polyfillCrypto.js.map +1 -1
- package/lib/servers/polyfill/polyfillFetch.js +23 -22
- package/lib/servers/polyfill/polyfillFetch.js.map +1 -1
- package/lib/servers/polyfill/polyfillJsDom.js +59 -52
- package/lib/servers/polyfill/polyfillJsDom.js.map +1 -1
- package/lib/servers/polyfill/polyfillWebSocket.js +13 -13
- package/lib/servers/polyfill/polyfillWebSocket.js.map +1 -1
- package/lib/servers/ws.js +3 -2
- package/lib/servers/ws.js.map +1 -1
- package/lib/strings/camelCase.js +51 -49
- package/lib/strings/camelCase.js.map +1 -1
- package/lib/strings/formatBytes.js +41 -15
- package/lib/strings/formatBytes.js.map +1 -1
- package/lib/strings/renderTemplate.js +27 -20
- package/lib/strings/renderTemplate.js.map +1 -1
- package/lib/typedoc.js +4 -0
- package/lib/typedoc.js.map +1 -0
- package/lib/types/global.d.js +2 -0
- package/lib/types/global.d.js.map +1 -0
- package/lib/types/index.d.js +6 -0
- package/lib/types/index.d.js.map +1 -0
- package/lib/validations/asserts.js +14 -0
- package/lib/validations/asserts.js.map +1 -0
- package/lib/validations/isUUID.js +3 -4
- package/lib/validations/isUUID.js.map +1 -1
- package/lib/validations/parseTimestamp.js +25 -21
- package/lib/validations/parseTimestamp.js.map +1 -1
- package/package.json +47 -47
- package/dist/LICENSE.txt +0 -1
- package/dist/cjs/createFetchWith-qhRObsE4.js +0 -2
- package/dist/cjs/createFetchWith-qhRObsE4.js.map +0 -1
- package/dist/cjs/getGlobalThis-GhffAgiG.js +0 -2
- package/dist/cjs/getGlobalThis-GhffAgiG.js.map +0 -1
- package/dist/cjs/index.cjs +0 -21
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/cjs/schema/typebox/gen/index.cjs +0 -118
- package/dist/cjs/schema/typebox/gen/index.cjs.map +0 -1
- package/dist/cjs/schema/typebox/index.cjs +0 -2
- package/dist/cjs/schema/typebox/index.cjs.map +0 -1
- package/dist/cjs/server.cjs +0 -2
- package/dist/cjs/server.cjs.map +0 -1
- package/dist/cjs/servers/jsdom.cjs +0 -2
- package/dist/cjs/servers/jsdom.cjs.map +0 -1
- package/dist/cjs/servers/node-fetch.cjs +0 -2
- package/dist/cjs/servers/node-fetch.cjs.map +0 -1
- package/dist/cjs/servers/ws.cjs +0 -2
- package/dist/cjs/servers/ws.cjs.map +0 -1
- package/dist/esm/createFetchWith-1q1S-Xro.js +0 -2
- package/dist/esm/createFetchWith-1q1S-Xro.js.map +0 -1
- package/dist/esm/getGlobalThis-A8F-nU7J.js +0 -2
- package/dist/esm/getGlobalThis-A8F-nU7J.js.map +0 -1
- package/dist/esm/index.js +0 -21
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/schema/typebox/gen.js +0 -118
- package/dist/esm/schema/typebox/gen.js.map +0 -1
- package/dist/esm/schema/typebox.js +0 -2
- package/dist/esm/schema/typebox.js.map +0 -1
- package/dist/esm/server.js +0 -2
- package/dist/esm/server.js.map +0 -1
- package/dist/esm/servers/jsdom.js +0 -2
- package/dist/esm/servers/jsdom.js.map +0 -1
- package/dist/esm/servers/node-fetch.js +0 -2
- package/dist/esm/servers/node-fetch.js.map +0 -1
- package/dist/esm/servers/ws.js +0 -2
- package/dist/esm/servers/ws.js.map +0 -1
- package/dist/system/createFetchWith-TjUle-dI.js +0 -2
- package/dist/system/createFetchWith-TjUle-dI.js.map +0 -1
- package/dist/system/getGlobalThis-X5ifUXDI.js +0 -2
- package/dist/system/getGlobalThis-X5ifUXDI.js.map +0 -1
- package/dist/system/index.js +0 -21
- package/dist/system/index.js.map +0 -1
- package/dist/system/schema/typebox/gen.js +0 -118
- package/dist/system/schema/typebox/gen.js.map +0 -1
- package/dist/system/schema/typebox.js +0 -2
- package/dist/system/schema/typebox.js.map +0 -1
- package/dist/system/server.js +0 -2
- package/dist/system/server.js.map +0 -1
- package/dist/system/servers/jsdom.js +0 -2
- package/dist/system/servers/jsdom.js.map +0 -1
- package/dist/system/servers/node-fetch.js +0 -2
- package/dist/system/servers/node-fetch.js.map +0 -1
- package/dist/system/servers/ws.js +0 -2
- package/dist/system/servers/ws.js.map +0 -1
package/lib/langs/deepEqual.js
CHANGED
|
@@ -1,95 +1,87 @@
|
|
|
1
1
|
const has = Object.prototype.hasOwnProperty;
|
|
2
|
-
const hasElementType = typeof Element !==
|
|
2
|
+
const hasElementType = typeof Element !== 'undefined';
|
|
3
3
|
function find(iter, tar, key) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return key;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
function deepEqual(foo, bar) {
|
|
10
|
-
let ctor, len, tmp;
|
|
11
|
-
if (foo === bar)
|
|
12
|
-
return true;
|
|
13
|
-
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
14
|
-
if (ctor === Date)
|
|
15
|
-
return foo.getTime() === bar.getTime();
|
|
16
|
-
if (ctor === RegExp)
|
|
17
|
-
return foo.toString() === bar.toString();
|
|
18
|
-
if (ctor === Array) {
|
|
19
|
-
if ((len = foo.length) === bar.length) {
|
|
20
|
-
while (len-- && deepEqual(foo[len], bar[len]))
|
|
21
|
-
;
|
|
22
|
-
}
|
|
23
|
-
return len === -1;
|
|
4
|
+
for (key of iter.keys()){
|
|
5
|
+
if (deepEqual(key, tar)) return key;
|
|
24
6
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* deep equal - support react, dom, Date, RegExp, Array, ArrayBuffer, Set, Map, Object
|
|
10
|
+
* @see {@link https://github.com/lukeed/dequal/blob/master/src/lite.js dequal/src/lite.js}
|
|
11
|
+
* @see {@link https://github.com/FormidableLabs/react-fast-compare/blob/master/index.js react-fast-compare/index.js}
|
|
12
|
+
*/ export function deepEqual(foo, bar) {
|
|
13
|
+
let ctor, len, tmp;
|
|
14
|
+
if (foo === bar) return true;
|
|
15
|
+
if (foo && bar && (ctor = foo.constructor) === bar.constructor) {
|
|
16
|
+
if (ctor === Date) return foo.getTime() === bar.getTime();
|
|
17
|
+
if (ctor === RegExp) return foo.toString() === bar.toString();
|
|
18
|
+
if (ctor === Array) {
|
|
19
|
+
if ((len = foo.length) === bar.length) {
|
|
20
|
+
while(len-- && deepEqual(foo[len], bar[len]));
|
|
21
|
+
}
|
|
22
|
+
return len === -1;
|
|
35
23
|
}
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
if (!tmp)
|
|
50
|
-
return false;
|
|
24
|
+
if (ctor === Set) {
|
|
25
|
+
if (foo.size !== bar.size) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
for (len of foo){
|
|
29
|
+
tmp = len;
|
|
30
|
+
if (tmp && typeof tmp === 'object') {
|
|
31
|
+
tmp = find(bar, tmp);
|
|
32
|
+
if (!tmp) return false;
|
|
33
|
+
}
|
|
34
|
+
if (!bar.has(tmp)) return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
51
37
|
}
|
|
52
|
-
if (
|
|
53
|
-
|
|
38
|
+
if (ctor === Map) {
|
|
39
|
+
if (foo.size !== bar.size) {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
for (len of foo){
|
|
43
|
+
tmp = len[0];
|
|
44
|
+
if (tmp && typeof tmp === 'object') {
|
|
45
|
+
tmp = find(bar, tmp);
|
|
46
|
+
if (!tmp) return false;
|
|
47
|
+
}
|
|
48
|
+
if (!deepEqual(len[1], bar.get(tmp))) {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return true;
|
|
54
53
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
54
|
+
if (ctor === ArrayBuffer) {
|
|
55
|
+
foo = new Uint8Array(foo);
|
|
56
|
+
bar = new Uint8Array(bar);
|
|
57
|
+
} else if (ctor === DataView) {
|
|
58
|
+
if ((len = foo.byteLength) === bar.byteLength) {
|
|
59
|
+
while(len-- && foo.getInt8(len) === bar.getInt8(len));
|
|
60
|
+
}
|
|
61
|
+
return len === -1;
|
|
62
|
+
}
|
|
63
|
+
if (ArrayBuffer.isView(foo)) {
|
|
64
|
+
if ((len = foo.byteLength) === bar.byteLength) {
|
|
65
|
+
while(len-- && foo[len] === bar[len]);
|
|
66
|
+
}
|
|
67
|
+
return len === -1;
|
|
68
|
+
}
|
|
69
|
+
// react & dom
|
|
70
|
+
if (hasElementType && foo instanceof Element) return false;
|
|
71
|
+
if (!ctor || typeof foo === 'object') {
|
|
72
|
+
len = 0;
|
|
73
|
+
for(ctor in foo){
|
|
74
|
+
if ((ctor === '_owner' || ctor === '__v' || ctor === '__o') && foo.$$typeof) {
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;
|
|
78
|
+
if (!(ctor in bar) || !deepEqual(foo[ctor], bar[ctor])) return false;
|
|
79
|
+
}
|
|
80
|
+
return Object.keys(bar).length === len;
|
|
82
81
|
}
|
|
83
|
-
if (has.call(foo, ctor) && ++len && !has.call(bar, ctor))
|
|
84
|
-
return false;
|
|
85
|
-
if (!(ctor in bar) || !deepEqual(foo[ctor], bar[ctor]))
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
return Object.keys(bar).length === len;
|
|
89
82
|
}
|
|
90
|
-
|
|
91
|
-
|
|
83
|
+
// eslint-disable-next-line no-self-compare
|
|
84
|
+
return foo !== foo && bar !== bar;
|
|
92
85
|
}
|
|
93
86
|
|
|
94
|
-
|
|
95
|
-
//# sourceMappingURL=deepEqual.js.map
|
|
87
|
+
//# sourceMappingURL=deepEqual.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/deepEqual.ts"],"sourcesContent":["const has = Object.prototype.hasOwnProperty;\nconst hasElementType = typeof Element !== 'undefined';\n\nfunction find(iter: any, tar: any, key?: any) {\n for (key of iter.keys()) {\n if (deepEqual(key, tar)) return key;\n }\n}\n\n/**\n * deep equal - support react, dom, Date, RegExp, Array, ArrayBuffer, Set, Map, Object\n * @see {@link https://github.com/lukeed/dequal/blob/master/src/lite.js dequal/src/lite.js}\n * @see {@link https://github.com/FormidableLabs/react-fast-compare/blob/master/index.js react-fast-compare/index.js}\n */\nexport function deepEqual(foo: any, bar: any) {\n let ctor, len, tmp;\n if (foo === bar) return true;\n\n if (foo && bar && (ctor = foo.constructor) === bar.constructor) {\n if (ctor === Date) return foo.getTime() === bar.getTime();\n if (ctor === RegExp) return foo.toString() === bar.toString();\n\n if (ctor === Array) {\n if ((len = foo.length) === bar.length) {\n while (len-- && deepEqual(foo[len], bar[len]));\n }\n return len === -1;\n }\n\n if (ctor === Set) {\n if (foo.size !== bar.size) {\n return false;\n }\n for (len of foo) {\n tmp = len;\n if (tmp && typeof tmp === 'object') {\n tmp = find(bar, tmp);\n if (!tmp) return false;\n }\n if (!bar.has(tmp)) return false;\n }\n return true;\n }\n\n if (ctor === Map) {\n if (foo.size !== bar.size) {\n return false;\n }\n for (len of foo) {\n tmp = len[0];\n if (tmp && typeof tmp === 'object') {\n tmp = find(bar, tmp);\n if (!tmp) return false;\n }\n if (!deepEqual(len[1], bar.get(tmp))) {\n return false;\n }\n }\n return true;\n }\n\n if (ctor === ArrayBuffer) {\n foo = new Uint8Array(foo);\n bar = new Uint8Array(bar);\n } else if (ctor === DataView) {\n if ((len = foo.byteLength) === bar.byteLength) {\n while (len-- && foo.getInt8(len) === bar.getInt8(len));\n }\n return len === -1;\n }\n\n if (ArrayBuffer.isView(foo)) {\n if ((len = foo.byteLength) === bar.byteLength) {\n while (len-- && (foo as any)[len] === bar[len]);\n }\n return len === -1;\n }\n\n // react & dom\n if (hasElementType && foo instanceof Element) return false;\n\n if (!ctor || typeof foo === 'object') {\n len = 0;\n for (ctor in foo) {\n if ((ctor === '_owner' || ctor === '__v' || ctor === '__o') && foo.$$typeof) {\n // React-specific: avoid traversing React elements' _owner\n // Preact-specific: avoid traversing Preact elements' __v and __o\n // __v = $_original / $_vnode\n // __o = $_owner\n // These properties contain circular references and are not needed when\n // comparing the actual elements (and not their owners)\n // .$$typeof and ._store on just reasonable markers of elements\n\n continue;\n }\n\n if (has.call(foo, ctor) && ++len && !has.call(bar, ctor)) return false;\n if (!(ctor in bar) || !deepEqual(foo[ctor], bar[ctor])) return false;\n }\n return Object.keys(bar).length === len;\n }\n }\n\n // eslint-disable-next-line no-self-compare\n return foo !== foo && bar !== bar;\n}\n"],"names":["has","Object","prototype","hasOwnProperty","hasElementType","Element","find","iter","tar","key","keys","deepEqual","foo","bar","ctor","len","tmp","constructor","Date","getTime","RegExp","toString","Array","length","Set","size","Map","get","ArrayBuffer","Uint8Array","DataView","byteLength","getInt8","isView","$$typeof","call"],"mappings":"AAAA,MAAMA,MAAMC,OAAOC,SAAS,CAACC,cAAc;AAC3C,MAAMC,iBAAiB,OAAOC,YAAY;AAE1C,SAASC,KAAKC,IAAS,EAAEC,GAAQ,EAAEC,GAAS;IAC1C,KAAKA,OAAOF,KAAKG,IAAI,GAAI;QACvB,IAAIC,UAAUF,KAAKD,MAAM,OAAOC;IAClC;AACF;AAEA;;;;CAIC,GACD,OAAO,SAASE,UAAUC,GAAQ,EAAEC,GAAQ;IAC1C,IAAIC,MAAMC,KAAKC;IACf,IAAIJ,QAAQC,KAAK,OAAO;IAExB,IAAID,OAAOC,OAAO,AAACC,CAAAA,OAAOF,IAAIK,WAAW,AAAD,MAAOJ,IAAII,WAAW,EAAE;QAC9D,IAAIH,SAASI,MAAM,OAAON,IAAIO,OAAO,OAAON,IAAIM,OAAO;QACvD,IAAIL,SAASM,QAAQ,OAAOR,IAAIS,QAAQ,OAAOR,IAAIQ,QAAQ;QAE3D,IAAIP,SAASQ,OAAO;YAClB,IAAI,AAACP,CAAAA,MAAMH,IAAIW,MAAM,AAAD,MAAOV,IAAIU,MAAM,EAAE;gBACrC,MAAOR,SAASJ,UAAUC,GAAG,CAACG,IAAI,EAAEF,GAAG,CAACE,IAAI;YAC9C;YACA,OAAOA,QAAQ,CAAC;QAClB;QAEA,IAAID,SAASU,KAAK;YAChB,IAAIZ,IAAIa,IAAI,KAAKZ,IAAIY,IAAI,EAAE;gBACzB,OAAO;YACT;YACA,KAAKV,OAAOH,IAAK;gBACfI,MAAMD;gBACN,IAAIC,OAAO,OAAOA,QAAQ,UAAU;oBAClCA,MAAMV,KAAKO,KAAKG;oBAChB,IAAI,CAACA,KAAK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EAAE;oBAS3E;gBACF;gBAEA,IAAIlC,IAAImC,IAAI,CAACvB,KAAKE,SAAS,EAAEC,OAAO,CAACf,IAAImC,IAAI,CAACtB,KAAKC,OAAO,OAAO;gBACjE,IAAI,CAAEA,CAAAA,QAAQD,GAAE,KAAM,CAACF,UAAUC,GAAG,CAACE,KAAK,EAAED,GAAG,CAACC,KAAK,GAAG,OAAO;YACjE;YACA,OAAOb,OAAOS,IAAI,CAACG,KAAKU,MAAM,KAAKR;QACrC;IACF;IAEA,2CAA2C;IAC3C,OAAOH,QAAQA,OAAOC,QAAQA;AAChC"}
|
package/lib/langs/deepFreeze.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
deepFreeze(value);
|
|
1
|
+
/**
|
|
2
|
+
* Freezes the given object and all its nested objects recursively.
|
|
3
|
+
*
|
|
4
|
+
* @param {T} obj - The object to freeze.
|
|
5
|
+
* @returns {T} - The frozen object.
|
|
6
|
+
*/ export function deepFreeze(obj) {
|
|
7
|
+
if (obj === null || typeof obj !== 'object') {
|
|
8
|
+
return obj;
|
|
10
9
|
}
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const props = Object.getOwnPropertyNames(obj);
|
|
11
|
+
for (const prop of props){
|
|
12
|
+
const value = obj[prop];
|
|
13
|
+
if (value && typeof value === 'object') {
|
|
14
|
+
deepFreeze(value);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return Object.freeze(obj);
|
|
13
18
|
}
|
|
14
19
|
|
|
15
|
-
|
|
16
|
-
//# sourceMappingURL=deepFreeze.js.map
|
|
20
|
+
//# sourceMappingURL=deepFreeze.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/deepFreeze.ts"],"sourcesContent":["/**\n * Freezes the given object and all its nested objects recursively.\n *\n * @param {T} obj - The object to freeze.\n * @returns {T} - The frozen object.\n */\nexport function deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== 'object') {\n return obj;\n }\n const props = Object.getOwnPropertyNames(obj);\n for (const prop of props) {\n const value = (obj as any)[prop];\n if (value && typeof value === 'object') {\n deepFreeze(value);\n }\n }\n return Object.freeze(obj);\n}\n"],"names":["deepFreeze","obj","props","Object","getOwnPropertyNames","prop","value","freeze"],"mappings":"AAAA;;;;;CAKC,GACD,OAAO,SAASA,WAAcC,GAAM;IAClC,IAAIA,QAAQ,QAAQ,OAAOA,QAAQ,UAAU;QAC3C,OAAOA;IACT;IACA,MAAMC,QAAQC,OAAOC,mBAAmB,CAACH;IACzC,KAAK,MAAMI,QAAQH,MAAO;QACxB,MAAMI,QAAQ,AAACL,GAAW,CAACI,KAAK;QAChC,IAAIC,SAAS,OAAOA,UAAU,UAAU;YACtCN,WAAWM;QACb;IACF;IACA,OAAOH,OAAOI,MAAM,CAACN;AACvB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
function sortObjectKeys(obj) {
|
|
2
|
+
if (obj === null || obj === undefined) {
|
|
3
|
+
return obj;
|
|
4
|
+
}
|
|
5
|
+
if (typeof obj !== 'object') {
|
|
6
|
+
// it is a primitive: number/string (in an array)
|
|
7
|
+
return obj;
|
|
8
|
+
}
|
|
9
|
+
return Object.keys(obj).sort().reduce((acc, key)=>{
|
|
10
|
+
if (Array.isArray(obj[key])) {
|
|
11
|
+
acc[key] = obj[key].map(sortObjectKeys);
|
|
12
|
+
} else if (typeof obj[key] === 'object') {
|
|
13
|
+
acc[key] = sortObjectKeys(obj[key]);
|
|
14
|
+
} else {
|
|
15
|
+
acc[key] = obj[key];
|
|
16
|
+
}
|
|
17
|
+
return acc;
|
|
18
|
+
}, {});
|
|
19
|
+
}
|
|
20
|
+
function toDeterministicJson(o) {
|
|
21
|
+
// https://github.com/kikobeats/json-stringify-deterministic
|
|
22
|
+
// https://stackoverflow.com/a/54902696/1870054
|
|
23
|
+
// https://github.com/sinclairzx81/typebox#hash
|
|
24
|
+
// https://github.com/sinclairzx81/typebox/blob/master/src/value/hash.ts
|
|
25
|
+
// LCS longest common subsequence
|
|
26
|
+
// https://github.com/sinclairzx81/typebox/issues/272
|
|
27
|
+
let sorted = sortObjectKeys(o);
|
|
28
|
+
let out = JSON.stringify(sorted, function(_, v) {
|
|
29
|
+
return v === undefined ? 'undef' : v;
|
|
30
|
+
});
|
|
31
|
+
// Remove all whitespace
|
|
32
|
+
return out.replace(/\s+/g, '');
|
|
33
|
+
}
|
|
34
|
+
function visit(o, _v, ctx) {
|
|
35
|
+
const v = {
|
|
36
|
+
array: (o, ctx)=>o.map((x)=>v.visit(x, ctx)),
|
|
37
|
+
object: (o, ctx)=>{
|
|
38
|
+
return Object.fromEntries(Object.entries(o).map(([k, v])=>[
|
|
39
|
+
k,
|
|
40
|
+
v.visit(v, ctx)
|
|
41
|
+
]));
|
|
42
|
+
},
|
|
43
|
+
buffer: (o)=>{
|
|
44
|
+
return o;
|
|
45
|
+
},
|
|
46
|
+
boolean: (o)=>o,
|
|
47
|
+
number: (o)=>o,
|
|
48
|
+
string: (o)=>o,
|
|
49
|
+
symbol: (o)=>o,
|
|
50
|
+
bigint: (o)=>o,
|
|
51
|
+
date: (o)=>o,
|
|
52
|
+
null: (o)=>o,
|
|
53
|
+
undefined: (o)=>o,
|
|
54
|
+
unknown: (o, ctx)=>{
|
|
55
|
+
if (o instanceof Map) {
|
|
56
|
+
return new Map([
|
|
57
|
+
...o.entries()
|
|
58
|
+
].map(([k, v])=>[
|
|
59
|
+
k,
|
|
60
|
+
v.visit(v, ctx)
|
|
61
|
+
]));
|
|
62
|
+
}
|
|
63
|
+
if (o instanceof Set) {
|
|
64
|
+
return new Set([
|
|
65
|
+
...o.values()
|
|
66
|
+
].map((v)=>v.visit(v, ctx)));
|
|
67
|
+
}
|
|
68
|
+
return o;
|
|
69
|
+
},
|
|
70
|
+
visit: (o, ctx)=>{
|
|
71
|
+
if (o === null) {
|
|
72
|
+
return v.null(o, ctx);
|
|
73
|
+
}
|
|
74
|
+
switch(typeof o){
|
|
75
|
+
case 'object':
|
|
76
|
+
if (o instanceof ArrayBuffer) {
|
|
77
|
+
return v.buffer(o, ctx);
|
|
78
|
+
}
|
|
79
|
+
if (Array.isArray(o)) {
|
|
80
|
+
return v.array(o, ctx);
|
|
81
|
+
}
|
|
82
|
+
if (o instanceof Date) {
|
|
83
|
+
return v.date(o, ctx);
|
|
84
|
+
}
|
|
85
|
+
// plain object
|
|
86
|
+
if (o.constructor === Object) {
|
|
87
|
+
return v.object(o, ctx);
|
|
88
|
+
}
|
|
89
|
+
//
|
|
90
|
+
return v.unknown(o, ctx);
|
|
91
|
+
case 'boolean':
|
|
92
|
+
return v.boolean(o, ctx);
|
|
93
|
+
case 'number':
|
|
94
|
+
return v.number(o, ctx);
|
|
95
|
+
case 'string':
|
|
96
|
+
return v.string(o, ctx);
|
|
97
|
+
case 'symbol':
|
|
98
|
+
return v.symbol(o, ctx);
|
|
99
|
+
case 'bigint':
|
|
100
|
+
return v.bigint(o, ctx);
|
|
101
|
+
case 'undefined':
|
|
102
|
+
return v.undefined(o, ctx);
|
|
103
|
+
default:
|
|
104
|
+
return v.unknown(o, ctx);
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
..._v
|
|
108
|
+
};
|
|
109
|
+
return v.visit(o, ctx);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
//# sourceMappingURL=hashCode.ignored.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/langs/hashCode.ignored.ts"],"sourcesContent":["function sortObjectKeys(obj?: Record<string, any>) {\n if (obj === null || obj === undefined) {\n return obj;\n }\n if (typeof obj !== 'object') {\n // it is a primitive: number/string (in an array)\n return obj;\n }\n return Object.keys(obj)\n .sort()\n .reduce(\n (acc, key) => {\n if (Array.isArray(obj[key])) {\n acc[key] = obj[key].map(sortObjectKeys);\n } else if (typeof obj[key] === 'object') {\n acc[key] = sortObjectKeys(obj[key]);\n } else {\n acc[key] = obj[key];\n }\n return acc;\n },\n {} as Record<string, any>,\n );\n}\n\nfunction toDeterministicJson(o: any) {\n // https://github.com/kikobeats/json-stringify-deterministic\n // https://stackoverflow.com/a/54902696/1870054\n // https://github.com/sinclairzx81/typebox#hash\n // https://github.com/sinclairzx81/typebox/blob/master/src/value/hash.ts\n // LCS longest common subsequence\n // https://github.com/sinclairzx81/typebox/issues/272\n let sorted: any = sortObjectKeys(o);\n let out = JSON.stringify(sorted, function (_, v) {\n return v === undefined ? 'undef' : v;\n });\n\n // Remove all whitespace\n return out.replace(/\\s+/g, '');\n}\n\ninterface Visitor<C> {\n array: (o: any[], ctx: C) => any;\n object: (o: Record<string, any>, ctx: C) => any;\n boolean: (o: boolean, ctx: C) => any;\n number: (o: number, ctx: C) => any;\n string: (o: string, ctx: C) => any;\n symbol: (o: symbol, ctx: C) => any;\n bigint: (o: bigint, ctx: C) => any;\n date: (o: Date, ctx: C) => any;\n buffer: (o: ArrayBuffer, ctx: C) => any;\n null: (o: null, ctx: C) => any;\n undefined: (o: undefined, ctx: C) => any;\n unknown: (o: unknown, ctx: C) => any;\n visit: (o: any, ctx: C) => any;\n}\n\nfunction visit<C>(o: any, _v: Partial<Visitor<C>>, ctx: C) {\n const v = {\n array: (o: any[], ctx: C): any => o.map((x) => v.visit(x, ctx)),\n object: (o: Record<string, any>, ctx: C) => {\n return Object.fromEntries(Object.entries(o).map(([k, v]) => [k, v.visit(v, ctx)]));\n },\n buffer: (o: ArrayBuffer) => {\n return o;\n },\n boolean: (o: boolean) => o,\n number: (o: number) => o,\n string: (o: string) => o,\n symbol: (o: symbol) => o,\n bigint: (o: bigint) => o,\n date: (o: Date) => o,\n null: (o: null) => o,\n undefined: (o: undefined) => o,\n unknown: (o: unknown, ctx: C): any => {\n if (o instanceof Map) {\n return new Map([...o.entries()].map(([k, v]) => [k, v.visit(v, ctx)]));\n }\n if (o instanceof Set) {\n return new Set([...o.values()].map((v) => v.visit(v, ctx)));\n }\n return o;\n },\n visit: (o: any, ctx: C): any => {\n if (o === null) {\n return v.null(o, ctx);\n }\n switch (typeof o) {\n case 'object':\n if (o instanceof ArrayBuffer) {\n return v.buffer(o, ctx);\n }\n if (Array.isArray(o)) {\n return v.array(o, ctx);\n }\n if (o instanceof Date) {\n return v.date(o, ctx);\n }\n // plain object\n if (o.constructor === Object) {\n return v.object(o, ctx);\n }\n //\n return v.unknown(o, ctx);\n case 'boolean':\n return v.boolean(o, ctx);\n case 'number':\n return v.number(o, ctx);\n case 'string':\n return v.string(o, ctx);\n case 'symbol':\n return v.symbol(o, ctx);\n case 'bigint':\n return v.bigint(o, ctx);\n case 'undefined':\n return v.undefined(o, ctx);\n default:\n return v.unknown(o, ctx);\n }\n },\n ..._v,\n };\n\n return v.visit(o, ctx);\n}\n"],"names":["sortObjectKeys","obj","undefined","Object","keys","sort","reduce","acc","key","Array","isArray","map","toDeterministicJson","o","sorted","out","JSON","stringify","_","v","replace","visit","_v","ctx","array","x","object","fromEntries","entries","k","buffer","boolean","number","string","symbol","bigint","date","null","unknown","Map","Set","values","ArrayBuffer","Date","constructor"],"mappings":"AAAA,SAASA,eAAeC,GAAyB;IAC/C,IAAIA,QAAQ,QAAQA,QAAQC,WAAW;QACrC,OAAOD;IACT;IACA,IAAI,OAAOA,QAAQ,UAAU;QAC3B,iDAAiD;QACjD,OAAOA;IACT;IACA,OAAOE,OAAOC,IAAI,CAACH,KAChBI,IAAI,GACJC,MAAM,CACL,CAACC,KAAKC;QACJ,IAAIC,MAAMC,OAAO,CAACT,GAAG,CAACO,IAAI,GAAG;YAC3BD,GAAG,CAACC,IAAI,GAAGP,GAAG,CAACO,IAAI,CAACG,GAAG,CAACX;QAC1B,OAAO,IAAI,OAAOC,GAAG,CAACO,IAAI,KAAK,UAAU;YACvCD,GAAG,CAACC,IAAI,GAAGR,eAAeC,GAAG,CAACO,IAAI;QACpC,OAAO;YACL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1,6 +1,5 @@
|
|
|
1
|
-
function isClass(func) {
|
|
2
|
-
|
|
1
|
+
export function isClass(func) {
|
|
2
|
+
return typeof func === 'function' && /^class\s/.test(Function.prototype.toString.call(func));
|
|
3
3
|
}
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
//# sourceMappingURL=isClass.js.map
|
|
5
|
+
//# sourceMappingURL=isClass.js.map
|
package/lib/langs/isClass.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/isClass.ts"],"sourcesContent":["export function isClass(func: any) {\n return typeof func === 'function' && /^class\\s/.test(Function.prototype.toString.call(func));\n}\n"],"names":["isClass","func","test","Function","prototype","toString","call"],"mappings":"AAAA,OAAO,SAASA,QAAQC,IAAS;IAC/B,OAAO,OAAOA,SAAS,cAAc,WAAWC,IAAI,CAACC,SAASC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACL;AACxF"}
|
package/lib/langs/isDefined.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/isDefined.ts"],"sourcesContent":["export function isDefined<T = any>(v: T): v is NonNullable<T> {\n return v !== null && v !== undefined;\n}\n"],"names":["isDefined","v","undefined"],"mappings":"AAAA,OAAO,SAASA,UAAmBC,CAAI;IACrC,OAAOA,MAAM,QAAQA,MAAMC;AAC7B"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { isPlainObject } from './isPlainObject.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return isPlainObject(o) && Object.keys(o).length === 0;
|
|
2
|
+
export function isEmptyObject(o) {
|
|
3
|
+
return isPlainObject(o) && Object.keys(o).length === 0;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
//# sourceMappingURL=isEmptyObject.js.map
|
|
6
|
+
//# sourceMappingURL=isEmptyObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/isEmptyObject.ts"],"sourcesContent":["import { isPlainObject } from './isPlainObject';\n\nexport function isEmptyObject(o: any) {\n return isPlainObject(o) && Object.keys(o).length === 0;\n}\n"],"names":["isPlainObject","isEmptyObject","o","Object","keys","length"],"mappings":"AAAA,SAASA,aAAa,QAAQ,kBAAkB;AAEhD,OAAO,SAASC,cAAcC,CAAM;IAClC,OAAOF,cAAcE,MAAMC,OAAOC,IAAI,CAACF,GAAGG,MAAM,KAAK;AACvD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/langs/isFunction.ts"],"sourcesContent":["export function isFunction(value: any): value is Function {\n return typeof value === 'function';\n}\n"],"names":["isFunction","value"],"mappings":"AAAA,OAAO,SAASA,WAAWC,KAAU;IACnC,OAAO,OAAOA,UAAU;AAC1B"}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { classOf } from './classOf.js';
|
|
2
|
-
|
|
3
|
-
function isPlainObject(value) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
// see: https://github.com/mesqueeb/is-what/blob/88d6e4ca92fb2baab6003c54e02eedf4e729e5ab/src/index.ts
|
|
3
|
+
export function isPlainObject(value) {
|
|
4
|
+
if (classOf(value) !== 'Object') {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
//# sourceMappingURL=isPlainObject.js.map
|
|
10
|
+
//# sourceMappingURL=isPlainObject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/isPlainObject.ts"],"sourcesContent":["import { classOf } from './classOf';\n\n// see: https://github.com/mesqueeb/is-what/blob/88d6e4ca92fb2baab6003c54e02eedf4e729e5ab/src/index.ts\n\nexport function isPlainObject(value: any): value is Record<string, any> {\n if (classOf(value) !== 'Object') {\n return false;\n }\n return value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;\n}\n"],"names":["classOf","isPlainObject","value","constructor","Object","getPrototypeOf","prototype"],"mappings":"AAAA,SAASA,OAAO,QAAQ,YAAY;AAEpC,sGAAsG;AAEtG,OAAO,SAASC,cAAcC,KAAU;IACtC,IAAIF,QAAQE,WAAW,UAAU;QAC/B,OAAO;IACT;IACA,OAAOA,MAAMC,WAAW,KAAKC,UAAUA,OAAOC,cAAc,CAACH,WAAWE,OAAOE,SAAS;AAC1F"}
|
package/lib/langs/memoize.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
function
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
throw new Error("`callback` should be a function");
|
|
6
|
-
}
|
|
7
|
-
if (resolver !== void 0 && typeof resolver !== "function") {
|
|
8
|
-
throw new Error("`resolver` should be a function");
|
|
9
|
-
}
|
|
10
|
-
const cache = {};
|
|
11
|
-
const memoized = function() {
|
|
12
|
-
const args = Array.prototype.slice.call(arguments);
|
|
13
|
-
const key = resolver.apply(this, args);
|
|
14
|
-
if (!(key in cache)) {
|
|
15
|
-
cache[key] = callback.apply(this, args);
|
|
1
|
+
// https://github.com/angus-c/just/blob/master/packages/function-memoize/index.mjs
|
|
2
|
+
export function memoize(callback, { resolver = (...args)=>JSON.stringify(args) } = {}) {
|
|
3
|
+
if (typeof callback !== 'function') {
|
|
4
|
+
throw new Error('`callback` should be a function');
|
|
16
5
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
6
|
+
if (resolver !== undefined && typeof resolver !== 'function') {
|
|
7
|
+
throw new Error('`resolver` should be a function');
|
|
8
|
+
}
|
|
9
|
+
const cache = {};
|
|
10
|
+
const memoized = function() {
|
|
11
|
+
const args = Array.prototype.slice.call(arguments); // to simplify JSON.stringify
|
|
12
|
+
const key = resolver.apply(this, args);
|
|
13
|
+
if (!(key in cache)) {
|
|
14
|
+
cache[key] = callback.apply(this, args);
|
|
15
|
+
}
|
|
16
|
+
return cache[key];
|
|
17
|
+
};
|
|
18
|
+
memoized.cache = cache;
|
|
19
|
+
return memoized;
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
//# sourceMappingURL=memoize.js.map
|
|
22
|
+
//# sourceMappingURL=memoize.js.map
|
package/lib/langs/memoize.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"sources":["../../src/langs/memoize.ts"],"sourcesContent":["// https://github.com/angus-c/just/blob/master/packages/function-memoize/index.mjs\ntype func = (...args: any) => any;\n\nexport function memoize<T extends func>(\n callback: T,\n {\n resolver = (...args: Parameters<T>) => JSON.stringify(args),\n }: { resolver?: (...args: Parameters<T>) => string } = {},\n): T {\n if (typeof callback !== 'function') {\n throw new Error('`callback` should be a function');\n }\n\n if (resolver !== undefined && typeof resolver !== 'function') {\n throw new Error('`resolver` should be a function');\n }\n\n const cache: Record<string, any> = {};\n\n const memoized = function (this: any) {\n const args = Array.prototype.slice.call(arguments); // to simplify JSON.stringify\n const key = resolver.apply(this, args as Parameters<T>);\n\n if (!(key in cache)) {\n cache[key] = callback.apply(this, args);\n }\n\n return cache[key];\n };\n memoized.cache = cache;\n return memoized as func as T;\n}\n"],"names":["memoize","callback","resolver","args","JSON","stringify","Error","undefined","cache","memoized","Array","prototype","slice","call","arguments","key","apply"],"mappings":"AAAA,kFAAkF;AAGlF,OAAO,SAASA,QACdC,QAAW,EACX,EACEC,WAAW,CAAC,GAAGC,OAAwBC,KAAKC,SAAS,CAACF,KAAK,EACT,GAAG,CAAC,CAAC;IAEzD,IAAI,OAAOF,aAAa,YAAY;QAClC,MAAM,IAAIK,MAAM;IAClB;IAEA,IAAIJ,aAAaK,aAAa,OAAOL,aAAa,YAAY;QAC5D,MAAM,IAAII,MAAM;IAClB;IAEA,MAAME,QAA6B,CAAC;IAEpC,MAAMC,WAAW;QACf,MAAMN,OAAOO,MAAMC,SAAS,CAACC,KAAK,CAACC,IAAI,CAACC,YAAY,6BAA6B;QACjF,MAAMC,MAAMb,SAASc,KAAK,CAAC,IAAI,EAAEb;QAEjC,IAAI,CAAEY,CAAAA,OAAOP,KAAI,GAAI;YACnBA,KAAK,CAACO,IAAI,GAAGd,SAASe,KAAK,CAAC,IAAI,EAAEb;QACpC;QAEA,OAAOK,KAAK,CAACO,IAAI;IACnB;IACAN,SAASD,KAAK,GAAGA;IACjB,OAAOC;AACT"}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
function parseBoolean(s, strict = false) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
}
|
|
5
|
-
if (typeof s === "string") {
|
|
6
|
-
switch (s.toLowerCase()) {
|
|
7
|
-
case "f":
|
|
8
|
-
case "false":
|
|
9
|
-
case "0":
|
|
10
|
-
return false;
|
|
11
|
-
case "1":
|
|
12
|
-
case "t":
|
|
13
|
-
case "true":
|
|
14
|
-
return true;
|
|
1
|
+
export function parseBoolean(s, strict = false) {
|
|
2
|
+
if (typeof s === 'boolean') {
|
|
3
|
+
return s;
|
|
15
4
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
5
|
+
if (typeof s === 'string') {
|
|
6
|
+
switch(s.toLowerCase()){
|
|
7
|
+
case 'f':
|
|
8
|
+
case 'false':
|
|
9
|
+
case '0':
|
|
10
|
+
return false;
|
|
11
|
+
case '1':
|
|
12
|
+
case 't':
|
|
13
|
+
case 'true':
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
} else if (typeof s === 'number') {
|
|
17
|
+
switch(s){
|
|
18
|
+
case 0:
|
|
19
|
+
return false;
|
|
20
|
+
case 1:
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
22
23
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return Boolean(s);
|
|
24
|
+
if (strict) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
return Boolean(s);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
//# sourceMappingURL=parseBoolean.js.map
|
|
30
|
+
//# sourceMappingURL=parseBoolean.js.map
|