@gtkx/utils 1.0.0-rc.3 → 1.0.0
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/README.md +8 -9
- package/dist/array/index-before-or-end.d.ts +0 -12
- package/dist/array/index-before-or-end.d.ts.map +1 -1
- package/dist/array/index-before-or-end.js +0 -12
- package/dist/array/index-before-or-end.js.map +1 -1
- package/dist/array/index.d.ts +5 -5
- package/dist/array/index.js.map +1 -1
- package/dist/array/remove.d.ts +0 -11
- package/dist/array/remove.d.ts.map +1 -1
- package/dist/array/remove.js +0 -11
- package/dist/array/remove.js.map +1 -1
- package/dist/array/sort-strings-by.d.ts +0 -12
- package/dist/array/sort-strings-by.d.ts.map +1 -1
- package/dist/array/sort-strings-by.js +0 -12
- package/dist/array/sort-strings-by.js.map +1 -1
- package/dist/array/sort-strings.d.ts +0 -9
- package/dist/array/sort-strings.d.ts.map +1 -1
- package/dist/array/sort-strings.js +0 -9
- package/dist/array/sort-strings.js.map +1 -1
- package/dist/array/uniq-by.d.ts +0 -15
- package/dist/array/uniq-by.d.ts.map +1 -1
- package/dist/array/uniq-by.js +0 -15
- package/dist/array/uniq-by.js.map +1 -1
- package/dist/class/any-class.d.ts +2 -3
- package/dist/class/any-class.d.ts.map +1 -1
- package/dist/class/any-class.js.map +1 -1
- package/dist/class/get-parent-class.d.ts +1 -7
- package/dist/class/get-parent-class.d.ts.map +1 -1
- package/dist/class/get-parent-class.js +0 -6
- package/dist/class/get-parent-class.js.map +1 -1
- package/dist/class/index.d.ts +3 -3
- package/dist/class/index.js.map +1 -1
- package/dist/class/walk-class-chain.d.ts +1 -10
- package/dist/class/walk-class-chain.d.ts.map +1 -1
- package/dist/class/walk-class-chain.js +0 -9
- package/dist/class/walk-class-chain.js.map +1 -1
- package/dist/error/error-like.js.map +1 -1
- package/dist/error/error-message.d.ts +0 -10
- package/dist/error/error-message.d.ts.map +1 -1
- package/dist/error/error-message.js +0 -10
- package/dist/error/error-message.js.map +1 -1
- package/dist/error/format-child-process-error.d.ts +0 -9
- package/dist/error/format-child-process-error.d.ts.map +1 -1
- package/dist/error/format-child-process-error.js +0 -9
- package/dist/error/format-child-process-error.js.map +1 -1
- package/dist/error/index.d.ts +3 -3
- package/dist/error/index.js.map +1 -1
- package/dist/error/normalize-error.d.ts +0 -10
- package/dist/error/normalize-error.d.ts.map +1 -1
- package/dist/error/normalize-error.js +0 -10
- package/dist/error/normalize-error.js.map +1 -1
- package/dist/index.d.ts +12 -13
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/log/create-logger.d.ts +1 -12
- package/dist/log/create-logger.d.ts.map +1 -1
- package/dist/log/create-logger.js +0 -11
- package/dist/log/create-logger.js.map +1 -1
- package/dist/log/default-logger.d.ts +4 -30
- package/dist/log/default-logger.d.ts.map +1 -1
- package/dist/log/default-logger.js +3 -29
- package/dist/log/default-logger.js.map +1 -1
- package/dist/log/index.d.ts +5 -3
- package/dist/log/index.d.ts.map +1 -1
- package/dist/log/index.js +3 -1
- package/dist/log/index.js.map +1 -1
- package/dist/log/logger.d.ts +2 -43
- package/dist/log/logger.d.ts.map +1 -1
- package/dist/log/logger.js +3 -34
- package/dist/log/logger.js.map +1 -1
- package/dist/map/get-or-insert.d.ts +1 -16
- package/dist/map/get-or-insert.d.ts.map +1 -1
- package/dist/map/get-or-insert.js +0 -15
- package/dist/map/get-or-insert.js.map +1 -1
- package/dist/map/index.d.ts +1 -1
- package/dist/map/index.js.map +1 -1
- package/dist/object/index.d.ts +3 -3
- package/dist/object/index.js.map +1 -1
- package/dist/object/omit.d.ts +0 -12
- package/dist/object/omit.d.ts.map +1 -1
- package/dist/object/omit.js +0 -12
- package/dist/object/omit.js.map +1 -1
- package/dist/object/pick-by.d.ts +0 -12
- package/dist/object/pick-by.d.ts.map +1 -1
- package/dist/object/pick-by.js +0 -12
- package/dist/object/pick-by.js.map +1 -1
- package/dist/object/structured-clone.d.ts +0 -16
- package/dist/object/structured-clone.d.ts.map +1 -1
- package/dist/object/structured-clone.js +0 -16
- package/dist/object/structured-clone.js.map +1 -1
- package/dist/predicate/index.d.ts +6 -6
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/is-deep-equal.d.ts.map +1 -1
- package/dist/predicate/is-deep-equal.js +0 -13
- package/dist/predicate/is-deep-equal.js.map +1 -1
- package/dist/predicate/is-plain-object.d.ts +0 -14
- package/dist/predicate/is-plain-object.d.ts.map +1 -1
- package/dist/predicate/is-plain-object.js +0 -14
- package/dist/predicate/is-plain-object.js.map +1 -1
- package/dist/predicate/is-record.d.ts +0 -11
- package/dist/predicate/is-record.d.ts.map +1 -1
- package/dist/predicate/is-record.js +0 -11
- package/dist/predicate/is-record.js.map +1 -1
- package/dist/predicate/is-same-array-by.d.ts +0 -12
- package/dist/predicate/is-same-array-by.d.ts.map +1 -1
- package/dist/predicate/is-same-array-by.js +0 -12
- package/dist/predicate/is-same-array-by.js.map +1 -1
- package/dist/predicate/is-same-array.d.ts +0 -12
- package/dist/predicate/is-same-array.d.ts.map +1 -1
- package/dist/predicate/is-same-array.js +0 -12
- package/dist/predicate/is-same-array.js.map +1 -1
- package/dist/predicate/is-shallow-equal.d.ts.map +1 -1
- package/dist/predicate/is-shallow-equal.js +0 -14
- package/dist/predicate/is-shallow-equal.js.map +1 -1
- package/dist/process/exit-code-for-signal.d.ts +0 -11
- package/dist/process/exit-code-for-signal.d.ts.map +1 -1
- package/dist/process/exit-code-for-signal.js +0 -11
- package/dist/process/exit-code-for-signal.js.map +1 -1
- package/dist/process/index.d.ts +4 -3
- package/dist/process/index.d.ts.map +1 -1
- package/dist/process/index.js +2 -1
- package/dist/process/index.js.map +1 -1
- package/dist/process/install-graceful-shutdown.d.ts +1 -7
- package/dist/process/install-graceful-shutdown.d.ts.map +1 -1
- package/dist/process/install-graceful-shutdown.js +7 -13
- package/dist/process/install-graceful-shutdown.js.map +1 -1
- package/dist/process/kill-marked-processes.d.ts +4 -0
- package/dist/process/kill-marked-processes.d.ts.map +1 -0
- package/dist/process/kill-marked-processes.js +38 -0
- package/dist/process/kill-marked-processes.js.map +1 -0
- package/dist/process/process-guard.d.ts +2 -0
- package/dist/process/process-guard.d.ts.map +1 -0
- package/dist/process/process-guard.js +16 -0
- package/dist/process/process-guard.js.map +1 -0
- package/dist/process/resolve-executable.d.ts +2 -12
- package/dist/process/resolve-executable.d.ts.map +1 -1
- package/dist/process/resolve-executable.js +6 -14
- package/dist/process/resolve-executable.js.map +1 -1
- package/dist/process/spawn-with-parent-death-signal.d.ts +8 -0
- package/dist/process/spawn-with-parent-death-signal.d.ts.map +1 -0
- package/dist/process/spawn-with-parent-death-signal.js +50 -0
- package/dist/process/spawn-with-parent-death-signal.js.map +1 -0
- package/dist/set/drain.d.ts +0 -8
- package/dist/set/drain.d.ts.map +1 -1
- package/dist/set/drain.js +0 -8
- package/dist/set/drain.js.map +1 -1
- package/dist/set/index.d.ts +1 -1
- package/dist/set/index.js.map +1 -1
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js.map +1 -1
- package/dist/source/sanitize-identifier.d.ts +0 -11
- package/dist/source/sanitize-identifier.d.ts.map +1 -1
- package/dist/source/sanitize-identifier.js +0 -11
- package/dist/source/sanitize-identifier.js.map +1 -1
- package/dist/source/source-string-literal.d.ts +0 -10
- package/dist/source/source-string-literal.d.ts.map +1 -1
- package/dist/source/source-string-literal.js +0 -10
- package/dist/source/source-string-literal.js.map +1 -1
- package/dist/source/to-camel-identifier.d.ts +0 -10
- package/dist/source/to-camel-identifier.d.ts.map +1 -1
- package/dist/source/to-camel-identifier.js +0 -10
- package/dist/source/to-camel-identifier.js.map +1 -1
- package/dist/string/camel-case.d.ts +0 -14
- package/dist/string/camel-case.d.ts.map +1 -1
- package/dist/string/camel-case.js +0 -14
- package/dist/string/camel-case.js.map +1 -1
- package/dist/string/index.d.ts +5 -5
- package/dist/string/index.js.map +1 -1
- package/dist/string/kebab-case.d.ts +0 -11
- package/dist/string/kebab-case.d.ts.map +1 -1
- package/dist/string/kebab-case.js +0 -11
- package/dist/string/kebab-case.js.map +1 -1
- package/dist/string/lower-first.d.ts +0 -10
- package/dist/string/lower-first.d.ts.map +1 -1
- package/dist/string/lower-first.js +0 -10
- package/dist/string/lower-first.js.map +1 -1
- package/dist/string/pascal-case.d.ts +0 -13
- package/dist/string/pascal-case.d.ts.map +1 -1
- package/dist/string/pascal-case.js +0 -13
- package/dist/string/pascal-case.js.map +1 -1
- package/dist/string/upper-first.d.ts +0 -10
- package/dist/string/upper-first.d.ts.map +1 -1
- package/dist/string/upper-first.js +0 -10
- package/dist/string/upper-first.js.map +1 -1
- package/dist/util/index.d.ts +1 -1
- package/dist/util/index.js.map +1 -1
- package/dist/util/package-version.d.ts +1 -10
- package/dist/util/package-version.d.ts.map +1 -1
- package/dist/util/package-version.js +2 -11
- package/dist/util/package-version.js.map +1 -1
- package/package.json +1 -1
- package/src/array/index-before-or-end.ts +0 -12
- package/src/array/index.ts +5 -5
- package/src/array/remove.ts +0 -11
- package/src/array/sort-strings-by.ts +0 -12
- package/src/array/sort-strings.ts +0 -9
- package/src/array/uniq-by.ts +0 -15
- package/src/class/any-class.ts +2 -3
- package/src/class/get-parent-class.ts +1 -7
- package/src/class/index.ts +3 -3
- package/src/class/walk-class-chain.ts +2 -11
- package/src/error/error-like.ts +1 -1
- package/src/error/error-message.ts +1 -11
- package/src/error/format-child-process-error.ts +2 -11
- package/src/error/index.ts +3 -3
- package/src/error/normalize-error.ts +2 -12
- package/src/index.ts +12 -13
- package/src/log/create-logger.ts +1 -12
- package/src/log/default-logger.ts +4 -30
- package/src/log/index.ts +5 -3
- package/src/log/logger.ts +4 -45
- package/src/map/get-or-insert.ts +1 -16
- package/src/map/index.ts +1 -1
- package/src/object/index.ts +3 -3
- package/src/object/omit.ts +0 -12
- package/src/object/pick-by.ts +0 -12
- package/src/object/structured-clone.ts +1 -17
- package/src/predicate/index.ts +6 -6
- package/src/predicate/is-deep-equal.ts +2 -15
- package/src/predicate/is-plain-object.ts +0 -14
- package/src/predicate/is-record.ts +0 -11
- package/src/predicate/is-same-array-by.ts +0 -12
- package/src/predicate/is-same-array.ts +1 -13
- package/src/predicate/is-shallow-equal.ts +2 -16
- package/src/process/exit-code-for-signal.ts +0 -11
- package/src/process/index.ts +4 -3
- package/src/process/install-graceful-shutdown.ts +12 -18
- package/src/process/kill-marked-processes.ts +44 -0
- package/src/process/process-guard.ts +20 -0
- package/src/process/resolve-executable.ts +7 -14
- package/src/process/spawn-with-parent-death-signal.ts +74 -0
- package/src/set/drain.ts +0 -8
- package/src/set/index.ts +1 -1
- package/src/source/index.ts +3 -3
- package/src/source/sanitize-identifier.ts +0 -11
- package/src/source/source-string-literal.ts +0 -10
- package/src/source/to-camel-identifier.ts +2 -12
- package/src/string/camel-case.ts +2 -16
- package/src/string/index.ts +5 -5
- package/src/string/kebab-case.ts +0 -11
- package/src/string/lower-first.ts +0 -10
- package/src/string/pascal-case.ts +2 -15
- package/src/string/upper-first.ts +0 -10
- package/src/util/index.ts +1 -1
- package/src/util/package-version.ts +2 -11
- package/dist/function/call-method.d.ts +0 -3
- package/dist/function/call-method.d.ts.map +0 -1
- package/dist/function/call-method.js +0 -19
- package/dist/function/call-method.js.map +0 -1
- package/dist/function/index.d.ts +0 -2
- package/dist/function/index.d.ts.map +0 -1
- package/dist/function/index.js +0 -2
- package/dist/function/index.js.map +0 -1
- package/src/function/call-method.ts +0 -22
- package/src/function/index.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upper-first.js","sourceRoot":"","sources":["../../src/string/upper-first.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"upper-first.js","sourceRoot":"","sources":["../../src/string/upper-first.ts"],"names":[],"mappings":"AAAA,SAAS,UAAU,CAAC,GAAW;IAC3B,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,OAAO,EAAE,UAAU,EAAE,CAAC","sourcesContent":["function upperFirst(str: string): string {\n return str.charAt(0).toUpperCase() + str.slice(1);\n}\n\nexport { upperFirst };\n"]}
|
package/dist/util/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { packageVersion } from "./package-version.
|
|
1
|
+
export { packageVersion } from "./package-version.ts";
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/util/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { packageVersion } from \"./package-version.
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC","sourcesContent":["export { packageVersion } from \"./package-version.ts\";\n"]}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
* Reads the `version` field from the `package.json` next to the calling module.
|
|
3
|
-
*
|
|
4
|
-
* @param importMetaUrl - The caller's `import.meta.url`, used to resolve the sibling `package.json`.
|
|
5
|
-
* @returns The package's version string.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* packageVersion(import.meta.url); // "1.2.3"
|
|
9
|
-
*/
|
|
10
|
-
declare function packageVersion(importMetaUrl: string): string;
|
|
1
|
+
declare function packageVersion(importMetaUrl: string, specifier: string): string;
|
|
11
2
|
export { packageVersion };
|
|
12
3
|
//# sourceMappingURL=package-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../../src/util/package-version.ts"],"names":[],"mappings":"AAEA
|
|
1
|
+
{"version":3,"file":"package-version.d.ts","sourceRoot":"","sources":["../../src/util/package-version.ts"],"names":[],"mappings":"AAEA,iBAAS,cAAc,CAAC,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAExE;AAED,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
* @param importMetaUrl - The caller's `import.meta.url`, used to resolve the sibling `package.json`.
|
|
6
|
-
* @returns The package's version string.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* packageVersion(import.meta.url); // "1.2.3"
|
|
10
|
-
*/
|
|
11
|
-
function packageVersion(importMetaUrl) {
|
|
12
|
-
return createRequire(importMetaUrl)("../package.json").version;
|
|
2
|
+
function packageVersion(importMetaUrl, specifier) {
|
|
3
|
+
return createRequire(importMetaUrl)(specifier).version;
|
|
13
4
|
}
|
|
14
5
|
export { packageVersion };
|
|
15
6
|
//# sourceMappingURL=package-version.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"package-version.js","sourceRoot":"","sources":["../../src/util/package-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"package-version.js","sourceRoot":"","sources":["../../src/util/package-version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,SAAS,cAAc,CAAC,aAAqB,EAAE,SAAiB;IAC5D,OAAQ,aAAa,CAAC,aAAa,CAAC,CAAC,SAAS,CAAyB,CAAC,OAAO,CAAC;AACpF,CAAC;AAED,OAAO,EAAE,cAAc,EAAE,CAAC","sourcesContent":["import { createRequire } from \"node:module\";\n\nfunction packageVersion(importMetaUrl: string, specifier: string): string {\n return (createRequire(importMetaUrl)(specifier) as { version: string }).version;\n}\n\nexport { packageVersion };\n"]}
|
package/package.json
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Finds the index of the first item matching `before`, or `list.length` when `before` is `null` or
|
|
3
|
-
* nothing matches. Use it to resolve where a new item should be inserted so it lands before the
|
|
4
|
-
* referenced one, defaulting to the end.
|
|
5
|
-
*
|
|
6
|
-
* @template T - The list item type.
|
|
7
|
-
* @template B - The reference value type.
|
|
8
|
-
* @param list - The list to search.
|
|
9
|
-
* @param before - The item to insert before, or `null` to target the end.
|
|
10
|
-
* @param isMatch - Called with each item and the non-null `before`; return `true` on a match.
|
|
11
|
-
* @returns The matched index, or `list.length`.
|
|
12
|
-
*/
|
|
13
1
|
const indexBeforeOrEnd = <T, B>(
|
|
14
2
|
list: T[],
|
|
15
3
|
before: B | null,
|
package/src/array/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { indexBeforeOrEnd } from "./index-before-or-end.
|
|
2
|
-
export { remove } from "./remove.
|
|
3
|
-
export { sortStringsBy } from "./sort-strings-by.
|
|
4
|
-
export { sortStrings } from "./sort-strings.
|
|
5
|
-
export { uniqBy } from "./uniq-by.
|
|
1
|
+
export { indexBeforeOrEnd } from "./index-before-or-end.ts";
|
|
2
|
+
export { remove } from "./remove.ts";
|
|
3
|
+
export { sortStringsBy } from "./sort-strings-by.ts";
|
|
4
|
+
export { sortStrings } from "./sort-strings.ts";
|
|
5
|
+
export { uniqBy } from "./uniq-by.ts";
|
package/src/array/remove.ts
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes the first strictly-equal (`===`) occurrence of `value` from `arr` in place.
|
|
3
|
-
*
|
|
4
|
-
* @template T - The type of the array elements.
|
|
5
|
-
* @param arr - The array to mutate.
|
|
6
|
-
* @param value - The value to remove.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* const items = ["a", "b", "c"];
|
|
10
|
-
* remove(items, "b"); // items is now ["a", "c"]
|
|
11
|
-
*/
|
|
12
1
|
function remove<T>(arr: T[], value: T): void {
|
|
13
2
|
const index = arr.indexOf(value);
|
|
14
3
|
|
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the items sorted by a string key using locale-aware comparison.
|
|
3
|
-
*
|
|
4
|
-
* @template T - The type of items being sorted.
|
|
5
|
-
* @param items - The items to sort.
|
|
6
|
-
* @param key - Maps an item to the string its order is decided by.
|
|
7
|
-
* @returns A new array of the items in ascending locale order of their keys.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* sortStringsBy([{ name: "b" }, { name: "a" }], (item) => item.name);
|
|
11
|
-
* // [{ name: "a" }, { name: "b" }]
|
|
12
|
-
*/
|
|
13
1
|
function sortStringsBy<T>(items: Iterable<T>, key: (item: T) => string): T[] {
|
|
14
2
|
return [...items].toSorted((a, b) => key(a).localeCompare(key(b)));
|
|
15
3
|
}
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns the values sorted as strings using locale-aware comparison.
|
|
3
|
-
*
|
|
4
|
-
* @param values - The strings to sort.
|
|
5
|
-
* @returns A new array of the values in ascending locale order.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* sortStrings(["b", "a", "c"]); // ["a", "b", "c"]
|
|
9
|
-
*/
|
|
10
1
|
function sortStrings(values: Iterable<string>): string[] {
|
|
11
2
|
return [...values].toSorted((a, b) => a.localeCompare(b));
|
|
12
3
|
}
|
package/src/array/uniq-by.ts
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a new array of the unique elements of `arr`, keyed by the value the `mapper` returns.
|
|
3
|
-
*
|
|
4
|
-
* When two elements map to the same key the first occurrence is kept and later ones discarded,
|
|
5
|
-
* preserving first-seen order.
|
|
6
|
-
*
|
|
7
|
-
* @template T - The type of elements in the array.
|
|
8
|
-
* @param arr - The array to deduplicate.
|
|
9
|
-
* @param mapper - Maps an element to the key its uniqueness is decided by.
|
|
10
|
-
* @returns A new array containing only the first element seen for each distinct key.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* uniqBy([2.1, 1.2, 2.3], Math.floor); // [2.1, 1.2]
|
|
14
|
-
* uniqBy([{ id: "a" }, { id: "a" }, { id: "b" }], (item) => item.id); // [{ id: "a" }, { id: "b" }]
|
|
15
|
-
*/
|
|
16
1
|
function uniqBy<T>(arr: T[], mapper: (item: T, index: number, array: T[]) => unknown): T[] {
|
|
17
2
|
const seen: Map<unknown, T> = new Map();
|
|
18
3
|
let index = 0;
|
package/src/class/any-class.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A constructor value of any (possibly abstract) class producing instances of `T`.
|
|
3
|
-
*/
|
|
1
|
+
/** Any class constructor, abstract ones included, whose instances are `T`. */
|
|
4
2
|
type AnyClass<T extends object = object> = (abstract new (
|
|
5
3
|
...args: never[]
|
|
6
4
|
) => T) & {
|
|
5
|
+
/** Object the class's instances inherit from. */
|
|
7
6
|
prototype: T;
|
|
8
7
|
};
|
|
9
8
|
|
|
@@ -1,11 +1,5 @@
|
|
|
1
|
-
import type { AnyClass } from "./any-class.
|
|
1
|
+
import type { AnyClass } from "./any-class.ts";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Returns the direct superclass of `cls`, or `null` when it has no class ancestor.
|
|
5
|
-
*
|
|
6
|
-
* @param cls - The class whose prototype parent to inspect.
|
|
7
|
-
* @returns The parent class, or `null` when there is none.
|
|
8
|
-
*/
|
|
9
3
|
function getParentClass(cls: AnyClass): AnyClass | null {
|
|
10
4
|
const parent: unknown = Object.getPrototypeOf(cls);
|
|
11
5
|
|
package/src/class/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export type { AnyClass } from "./any-class.
|
|
2
|
-
export { getParentClass } from "./get-parent-class.
|
|
3
|
-
export { walkClassChain } from "./walk-class-chain.
|
|
1
|
+
export type { AnyClass } from "./any-class.ts";
|
|
2
|
+
export { getParentClass } from "./get-parent-class.ts";
|
|
3
|
+
export { walkClassChain } from "./walk-class-chain.ts";
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import type { AnyClass } from "./any-class.
|
|
2
|
-
import { getParentClass } from "./get-parent-class.
|
|
1
|
+
import type { AnyClass } from "./any-class.ts";
|
|
2
|
+
import { getParentClass } from "./get-parent-class.ts";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Walks the class chain from `cls` up through its ancestors, calling `visit` on each and returning
|
|
6
|
-
* the first result that is not `undefined`.
|
|
7
|
-
*
|
|
8
|
-
* @template T - The type produced by the visitor.
|
|
9
|
-
* @param cls - The class to start from, or `null` to visit nothing.
|
|
10
|
-
* @param visit - Called with each class in the chain; a defined return value stops the walk.
|
|
11
|
-
* @returns The first defined result from `visit`, or `undefined` when none was produced.
|
|
12
|
-
*/
|
|
13
4
|
function walkClassChain<T>(cls: AnyClass | null, visit: (ancestor: AnyClass) => T | undefined): T | undefined {
|
|
14
5
|
let current = cls;
|
|
15
6
|
|
package/src/error/error-like.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
import { isErrorLike } from "./error-like.
|
|
1
|
+
import { isErrorLike } from "./error-like.ts";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Extracts a human-readable message from an unknown thrown value, falling back to its string form.
|
|
5
|
-
*
|
|
6
|
-
* @param error - The caught value to describe.
|
|
7
|
-
* @returns The value's message when it has one, otherwise its string form.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* errorMessage(new Error("boom")); // "boom"
|
|
11
|
-
* errorMessage(42); // "42"
|
|
12
|
-
*/
|
|
13
3
|
function errorMessage(error: unknown): string {
|
|
14
4
|
return Error.isError(error) || isErrorLike(error) ? error.message : String(error);
|
|
15
5
|
}
|
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
import { isRecord } from "../predicate/is-record.
|
|
2
|
-
import { readStream } from "./error-like.
|
|
1
|
+
import { isRecord } from "../predicate/is-record.ts";
|
|
2
|
+
import { readStream } from "./error-like.ts";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Combines the `stderr` and `stdout` of a failed child-process error into a single trimmed string.
|
|
6
|
-
*
|
|
7
|
-
* @param error - The child-process error to read output from.
|
|
8
|
-
* @returns The joined output, or `undefined` when neither stream carried any text.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* formatChildProcessError({ stderr: "boom" }); // "boom"
|
|
12
|
-
*/
|
|
13
4
|
function formatChildProcessError(error: unknown): string | undefined {
|
|
14
5
|
if (!isRecord(error)) {
|
|
15
6
|
return undefined;
|
package/src/error/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { errorMessage } from "./error-message.
|
|
2
|
-
export { formatChildProcessError } from "./format-child-process-error.
|
|
3
|
-
export { normalizeError } from "./normalize-error.
|
|
1
|
+
export { errorMessage } from "./error-message.ts";
|
|
2
|
+
export { formatChildProcessError } from "./format-child-process-error.ts";
|
|
3
|
+
export { normalizeError } from "./normalize-error.ts";
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import { isErrorLike } from "./error-like.
|
|
2
|
-
import { errorMessage } from "./error-message.
|
|
1
|
+
import { isErrorLike } from "./error-like.ts";
|
|
2
|
+
import { errorMessage } from "./error-message.ts";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Coerces an unknown thrown value into an `Error`, reusing it when it already is one and otherwise
|
|
6
|
-
* wrapping its message while copying any error-like own properties.
|
|
7
|
-
*
|
|
8
|
-
* @param error - The caught value to normalize.
|
|
9
|
-
* @returns The value itself when it is an `Error`, otherwise a new `Error` carrying its message.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* normalizeError("boom"); // Error: boom
|
|
13
|
-
*/
|
|
14
4
|
function normalizeError(error: unknown): Error {
|
|
15
5
|
if (Error.isError(error)) {
|
|
16
6
|
return error;
|
package/src/index.ts
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
export * from "./array/index.
|
|
2
|
-
export * from "./class/index.
|
|
3
|
-
export * from "./error/index.
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./
|
|
11
|
-
export * from "./
|
|
12
|
-
export * from "./
|
|
13
|
-
export * from "./util/index.js";
|
|
1
|
+
export * from "./array/index.ts";
|
|
2
|
+
export * from "./class/index.ts";
|
|
3
|
+
export * from "./error/index.ts";
|
|
4
|
+
export * from "./log/index.ts";
|
|
5
|
+
export * from "./map/index.ts";
|
|
6
|
+
export * from "./object/index.ts";
|
|
7
|
+
export * from "./predicate/index.ts";
|
|
8
|
+
export * from "./process/index.ts";
|
|
9
|
+
export * from "./set/index.ts";
|
|
10
|
+
export * from "./source/index.ts";
|
|
11
|
+
export * from "./string/index.ts";
|
|
12
|
+
export * from "./util/index.ts";
|
package/src/log/create-logger.ts
CHANGED
|
@@ -1,16 +1,5 @@
|
|
|
1
|
-
import { Logger, type LoggerOptions } from "./logger.
|
|
1
|
+
import { Logger, type LoggerOptions } from "./logger.ts";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Creates a {@link Logger} scoped to the given namespace.
|
|
5
|
-
*
|
|
6
|
-
* @param namespace - Namespace added to the log prefix and matched against debug configuration.
|
|
7
|
-
* @param options - Further logger options, excluding the namespace.
|
|
8
|
-
* @returns A new namespaced logger.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* const log = createLogger("react");
|
|
12
|
-
* log.info("mounted");
|
|
13
|
-
*/
|
|
14
3
|
function createLogger(namespace: string, options: Omit<LoggerOptions, "namespace"> = {}): Logger {
|
|
15
4
|
return new Logger({ ...options, namespace });
|
|
16
5
|
}
|
|
@@ -1,49 +1,23 @@
|
|
|
1
|
-
import { Logger } from "./logger.
|
|
1
|
+
import { Logger } from "./logger.ts";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* The default namespace-less {@link Logger} backing the module-level {@link info}, {@link warn},
|
|
5
|
-
* {@link error}, and {@link debug} functions.
|
|
6
|
-
*/
|
|
7
3
|
const logger: Logger = new Logger();
|
|
8
4
|
|
|
9
|
-
/**
|
|
10
|
-
* Writes an informational line through the shared {@link logger}.
|
|
11
|
-
*
|
|
12
|
-
* @param message - The message text.
|
|
13
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
14
|
-
*/
|
|
15
5
|
function info(message: string, ...rest: unknown[]): void {
|
|
16
6
|
logger.info(message, ...rest);
|
|
17
7
|
}
|
|
18
8
|
|
|
19
|
-
/**
|
|
20
|
-
* Writes a warning line through the shared {@link logger}.
|
|
21
|
-
*
|
|
22
|
-
* @param message - The message text.
|
|
23
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
24
|
-
*/
|
|
25
9
|
function warn(message: string, ...rest: unknown[]): void {
|
|
26
10
|
logger.warn(message, ...rest);
|
|
27
11
|
}
|
|
28
12
|
|
|
29
|
-
/**
|
|
30
|
-
* Writes an error line through the shared {@link logger}.
|
|
31
|
-
*
|
|
32
|
-
* @param message - The message text.
|
|
33
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
34
|
-
*/
|
|
35
13
|
function error(message: string, ...rest: unknown[]): void {
|
|
36
14
|
logger.error(message, ...rest);
|
|
37
15
|
}
|
|
38
16
|
|
|
39
|
-
/**
|
|
40
|
-
* Writes a debug line through the shared {@link logger} when debug output is enabled.
|
|
41
|
-
*
|
|
42
|
-
* @param message - The message text.
|
|
43
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
44
|
-
*/
|
|
45
17
|
function debug(message: string, ...rest: unknown[]): void {
|
|
46
18
|
logger.debug(message, ...rest);
|
|
47
19
|
}
|
|
48
20
|
|
|
49
|
-
export { logger, info, warn, error
|
|
21
|
+
export { logger, info, warn, error };
|
|
22
|
+
/** @internal */
|
|
23
|
+
export { debug };
|
package/src/log/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
export { createLogger } from "./create-logger.
|
|
2
|
-
export {
|
|
3
|
-
|
|
1
|
+
export { createLogger } from "./create-logger.ts";
|
|
2
|
+
export { error, info, logger, warn } from "./default-logger.ts";
|
|
3
|
+
/** @internal */
|
|
4
|
+
export { debug } from "./default-logger.ts";
|
|
5
|
+
export { Logger, type OutputStream } from "./logger.ts";
|
package/src/log/logger.ts
CHANGED
|
@@ -2,25 +2,15 @@ import pc from "picocolors";
|
|
|
2
2
|
|
|
3
3
|
type Colors = ReturnType<typeof pc.createColors>;
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Minimal writable-stream shape a {@link Logger} writes formatted lines to.
|
|
7
|
-
*/
|
|
8
5
|
type OutputStream = {
|
|
9
6
|
write(chunk: string): unknown;
|
|
10
|
-
/** Whether the stream is a terminal, used to decide if colored output is emitted. */
|
|
11
7
|
isTTY?: boolean | undefined;
|
|
12
8
|
};
|
|
13
9
|
|
|
14
|
-
/**
|
|
15
|
-
* Options for constructing a {@link Logger}.
|
|
16
|
-
*/
|
|
17
10
|
type LoggerOptions = {
|
|
18
|
-
/** Namespace appended to the log prefix and matched against debug configuration. */
|
|
19
11
|
namespace?: string | undefined;
|
|
20
|
-
/** Stream to write log lines to; defaults to `process.stderr`. */
|
|
21
12
|
stream?: OutputStream | undefined;
|
|
22
|
-
|
|
23
|
-
debugEnabled?: boolean | undefined;
|
|
13
|
+
isDebugEnabled?: boolean | undefined;
|
|
24
14
|
};
|
|
25
15
|
|
|
26
16
|
const BASE_PREFIX = "[gtkx]";
|
|
@@ -69,23 +59,16 @@ function getPrefix(namespace: string | undefined): string {
|
|
|
69
59
|
return namespace === undefined ? BASE_PREFIX : `[gtkx:${namespace}]`;
|
|
70
60
|
}
|
|
71
61
|
|
|
72
|
-
/**
|
|
73
|
-
* Writes prefixed, optionally colored log lines to an output stream, with debug lines gated by
|
|
74
|
-
* command-line and environment configuration.
|
|
75
|
-
*/
|
|
76
62
|
class Logger {
|
|
77
63
|
private stream: OutputStream;
|
|
78
64
|
private prefix: string;
|
|
79
|
-
private
|
|
65
|
+
private isDebugEnabled: boolean;
|
|
80
66
|
private colors: Colors;
|
|
81
67
|
|
|
82
|
-
/**
|
|
83
|
-
* @param options - Namespace, target stream, and debug configuration for the logger.
|
|
84
|
-
*/
|
|
85
68
|
constructor(options: LoggerOptions = {}) {
|
|
86
69
|
this.stream = options.stream ?? process.stderr;
|
|
87
70
|
this.prefix = getPrefix(options.namespace);
|
|
88
|
-
this.
|
|
71
|
+
this.isDebugEnabled = options.isDebugEnabled ?? isDebugEnabled(options.namespace, process.argv, process.env);
|
|
89
72
|
this.colors = getColors(this.stream);
|
|
90
73
|
}
|
|
91
74
|
|
|
@@ -94,44 +77,20 @@ class Logger {
|
|
|
94
77
|
this.stream.write(`${this.prefix} ${message}${suffix}\n`);
|
|
95
78
|
}
|
|
96
79
|
|
|
97
|
-
/**
|
|
98
|
-
* Writes an informational line.
|
|
99
|
-
*
|
|
100
|
-
* @param message - The message text.
|
|
101
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
102
|
-
*/
|
|
103
80
|
info(message: string, ...rest: unknown[]): void {
|
|
104
81
|
this.write(message, rest);
|
|
105
82
|
}
|
|
106
83
|
|
|
107
|
-
/**
|
|
108
|
-
* Writes a line marked as a warning.
|
|
109
|
-
*
|
|
110
|
-
* @param message - The message text.
|
|
111
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
112
|
-
*/
|
|
113
84
|
warn(message: string, ...rest: unknown[]): void {
|
|
114
85
|
this.write(`${this.colors.yellow("warn")} ${message}`, rest);
|
|
115
86
|
}
|
|
116
87
|
|
|
117
|
-
/**
|
|
118
|
-
* Writes a line marked as an error.
|
|
119
|
-
*
|
|
120
|
-
* @param message - The message text.
|
|
121
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
122
|
-
*/
|
|
123
88
|
error(message: string, ...rest: unknown[]): void {
|
|
124
89
|
this.write(`${this.colors.red("error")} ${message}`, rest);
|
|
125
90
|
}
|
|
126
91
|
|
|
127
|
-
/**
|
|
128
|
-
* Writes a line only when debug output is enabled for this logger.
|
|
129
|
-
*
|
|
130
|
-
* @param message - The message text.
|
|
131
|
-
* @param rest - Extra values appended after the message, formatted for display.
|
|
132
|
-
*/
|
|
133
92
|
debug(message: string, ...rest: unknown[]): void {
|
|
134
|
-
if (!this.
|
|
93
|
+
if (!this.isDebugEnabled) {
|
|
135
94
|
return;
|
|
136
95
|
}
|
|
137
96
|
|
package/src/map/get-or-insert.ts
CHANGED
|
@@ -4,21 +4,6 @@ type GetSet<K, V> = {
|
|
|
4
4
|
has(key: K): boolean;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Returns the value stored under `key`, or inserts and returns the value produced by `factory` when
|
|
9
|
-
* the key is absent. Works with both `Map` and `WeakMap`, and caches a computed `undefined` value.
|
|
10
|
-
*
|
|
11
|
-
* @template K - The key type.
|
|
12
|
-
* @template V - The value type.
|
|
13
|
-
* @param map - The `Map` or `WeakMap` to read from and populate.
|
|
14
|
-
* @param key - The key to look up.
|
|
15
|
-
* @param factory - Produces the value to insert when `key` is absent; called at most once.
|
|
16
|
-
* @returns The existing or newly-inserted value.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* const counts = new Map<string, number[]>();
|
|
20
|
-
* getOrInsert(counts, "a", () => []).push(1); // counts is Map { "a" => [1] }
|
|
21
|
-
*/
|
|
22
7
|
function getOrInsert<K, V>(map: GetSet<K, V>, key: K, factory: (key: K) => V): V {
|
|
23
8
|
if (map.has(key)) {
|
|
24
9
|
return map.get(key) as V;
|
|
@@ -30,4 +15,4 @@ function getOrInsert<K, V>(map: GetSet<K, V>, key: K, factory: (key: K) => V): V
|
|
|
30
15
|
return value;
|
|
31
16
|
}
|
|
32
17
|
|
|
33
|
-
export { getOrInsert
|
|
18
|
+
export { getOrInsert };
|
package/src/map/index.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getOrInsert } from "./get-or-insert.
|
|
1
|
+
export { getOrInsert } from "./get-or-insert.ts";
|
package/src/object/index.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { omit } from "./omit.
|
|
2
|
-
export { pickBy } from "./pick-by.
|
|
3
|
-
export { structuredClone } from "./structured-clone.
|
|
1
|
+
export { omit } from "./omit.ts";
|
|
2
|
+
export { pickBy } from "./pick-by.ts";
|
|
3
|
+
export { structuredClone } from "./structured-clone.ts";
|
package/src/object/omit.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object holding every entry of `obj` except the named keys.
|
|
3
|
-
*
|
|
4
|
-
* @template T - The type of the source object.
|
|
5
|
-
* @template K - The keys to leave out.
|
|
6
|
-
* @param obj - The object to copy entries from.
|
|
7
|
-
* @param keys - The keys to leave out of the result.
|
|
8
|
-
* @returns A new object without the named keys.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* omit({ a: 1, b: 2 }, ["a"]); // { b: 2 }
|
|
12
|
-
*/
|
|
13
1
|
function omit<T extends object, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
|
|
14
2
|
const excluded: Set<PropertyKey> = new Set(keys);
|
|
15
3
|
const result: Record<string, unknown> = {};
|
package/src/object/pick-by.ts
CHANGED
|
@@ -1,15 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Creates a new object of the entries of `obj` that satisfy the predicate.
|
|
3
|
-
*
|
|
4
|
-
* @template T - The type of the source object.
|
|
5
|
-
* @param obj - The object to pick entries from.
|
|
6
|
-
* @param shouldPick - Called with each value and key; return `true` to keep the entry.
|
|
7
|
-
* @returns A new object holding only the entries the predicate kept.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* pickBy({ a: 1, b: 2 }, (value) => value > 1); // { b: 2 }
|
|
11
|
-
* pickBy({ a: 1, b: 2 }, (_value, key) => key !== "a"); // { b: 2 }
|
|
12
|
-
*/
|
|
13
1
|
function pickBy<T extends Record<string, unknown>>(
|
|
14
2
|
obj: T,
|
|
15
3
|
shouldPick: (value: T[keyof T], key: keyof T) => boolean,
|
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
import { isPlainObject } from "../predicate/is-plain-object.
|
|
1
|
+
import { isPlainObject } from "../predicate/is-plain-object.ts";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Recursively copies arrays and plain objects, sharing every other value by reference. The result
|
|
5
|
-
* mirrors exactly the structure `isDeepEqual` traverses, so comparing a value against its earlier
|
|
6
|
-
* clone detects in-place mutations of the original. Unlike the global of the same name, class
|
|
7
|
-
* instances such as `Date` and `Map` are shared rather than copied, and no value is ever rejected.
|
|
8
|
-
*
|
|
9
|
-
* @template T - The type of the value.
|
|
10
|
-
* @param value - The value to clone.
|
|
11
|
-
* @returns A clone whose arrays and plain objects are fresh and whose other values are shared.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* const source = { a: [{ b: 1 }] };
|
|
15
|
-
* const copy = structuredClone(source);
|
|
16
|
-
* source.a[0].b = 2;
|
|
17
|
-
* copy.a[0].b; // 1
|
|
18
|
-
*/
|
|
19
3
|
function structuredClone<T>(value: T): T {
|
|
20
4
|
if (Array.isArray(value)) {
|
|
21
5
|
return value.map((item: unknown) => structuredClone(item)) as T;
|
package/src/predicate/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { isDeepEqual } from "./is-deep-equal.
|
|
2
|
-
export { isPlainObject } from "./is-plain-object.
|
|
3
|
-
export { isRecord } from "./is-record.
|
|
4
|
-
export { isSameArrayBy } from "./is-same-array-by.
|
|
5
|
-
export { isSameArray } from "./is-same-array.
|
|
6
|
-
export { isShallowEqual } from "./is-shallow-equal.
|
|
1
|
+
export { isDeepEqual } from "./is-deep-equal.ts";
|
|
2
|
+
export { isPlainObject } from "./is-plain-object.ts";
|
|
3
|
+
export { isRecord } from "./is-record.ts";
|
|
4
|
+
export { isSameArrayBy } from "./is-same-array-by.ts";
|
|
5
|
+
export { isSameArray } from "./is-same-array.ts";
|
|
6
|
+
export { isShallowEqual } from "./is-shallow-equal.ts";
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
-
import { areObjectKeysEqual } from "./are-object-keys-equal.
|
|
2
|
-
import { isPlainObject } from "./is-plain-object.
|
|
1
|
+
import { areObjectKeysEqual } from "./are-object-keys-equal.ts";
|
|
2
|
+
import { isPlainObject } from "./is-plain-object.ts";
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* Checks whether two values are deeply equal: identical, arrays of the same length whose elements
|
|
6
|
-
* are deeply equal in order, or plain objects with the same own enumerable keys and deeply equal
|
|
7
|
-
* values. Values that are neither both arrays nor both plain objects are equal only when identical.
|
|
8
|
-
*
|
|
9
|
-
* @param a - The first value.
|
|
10
|
-
* @param b - The second value.
|
|
11
|
-
* @returns `true` when the values are deeply equal.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* isDeepEqual({ a: [1, { b: 2 }] }, { a: [1, { b: 2 }] }); // true
|
|
15
|
-
* isDeepEqual({ a: [1] }, { a: [2] }); // false
|
|
16
|
-
*/
|
|
17
4
|
const isDeepArrayEqual = (a: unknown, b: unknown): boolean => {
|
|
18
5
|
if (!Array.isArray(a) || !Array.isArray(b) || a.length !== b.length) {
|
|
19
6
|
return false;
|