es-toolkit 1.51.0-dev.2076 → 1.51.0-dev.2077
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/dist/object/omitBy.d.mts +4 -2
- package/dist/object/omitBy.d.ts +4 -2
- package/dist/object/omitBy.js +4 -3
- package/dist/object/omitBy.mjs +4 -3
- package/dist/object/pickBy.d.mts +4 -2
- package/dist/object/pickBy.d.ts +4 -2
- package/dist/object/pickBy.js +4 -3
- package/dist/object/pickBy.mjs +4 -3
- package/dist/types/ObjectKeys.d.mts +19 -0
- package/dist/types/ObjectKeys.d.ts +19 -0
- package/dist/types/index.d.mts +2 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/object/omitBy.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ObjectKeys } from "../types/ObjectKeys.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/object/omitBy.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
|
@@ -9,7 +11,7 @@
|
|
|
9
11
|
* @param obj - The object to omit properties from.
|
|
10
12
|
* @param shouldOmit - A predicate function that determines
|
|
11
13
|
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be omitted, and `false` otherwise.
|
|
14
|
+
* if the property should be omitted, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
15
|
* @returns A new object with the properties that do not satisfy the predicate function.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
@@ -18,6 +20,6 @@
|
|
|
18
20
|
* const result = omitBy(obj, shouldOmit);
|
|
19
21
|
* // result will be { a: 1, c: 3 }
|
|
20
22
|
*/
|
|
21
|
-
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key:
|
|
23
|
+
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: ObjectKeys<T>) => boolean): Partial<T>;
|
|
22
24
|
//#endregion
|
|
23
25
|
export { omitBy };
|
package/dist/object/omitBy.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ObjectKeys } from "../types/ObjectKeys.js";
|
|
2
|
+
|
|
1
3
|
//#region src/object/omitBy.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Creates a new object composed of the properties that do not satisfy the predicate function.
|
|
@@ -9,7 +11,7 @@
|
|
|
9
11
|
* @param obj - The object to omit properties from.
|
|
10
12
|
* @param shouldOmit - A predicate function that determines
|
|
11
13
|
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be omitted, and `false` otherwise.
|
|
14
|
+
* if the property should be omitted, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
15
|
* @returns A new object with the properties that do not satisfy the predicate function.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
@@ -18,6 +20,6 @@
|
|
|
18
20
|
* const result = omitBy(obj, shouldOmit);
|
|
19
21
|
* // result will be { a: 1, c: 3 }
|
|
20
22
|
*/
|
|
21
|
-
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key:
|
|
23
|
+
declare function omitBy<T extends Record<string, any>>(obj: T, shouldOmit: (value: T[keyof T], key: ObjectKeys<T>) => boolean): Partial<T>;
|
|
22
24
|
//#endregion
|
|
23
25
|
export { omitBy };
|
package/dist/object/omitBy.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param obj - The object to omit properties from.
|
|
10
10
|
* @param shouldOmit - A predicate function that determines
|
|
11
11
|
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be omitted, and `false` otherwise.
|
|
12
|
+
* if the property should be omitted, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
13
|
* @returns A new object with the properties that do not satisfy the predicate function.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
@@ -23,8 +23,9 @@ function omitBy(obj, shouldOmit) {
|
|
|
23
23
|
const keys = Object.keys(obj);
|
|
24
24
|
for (let i = 0; i < keys.length; i++) {
|
|
25
25
|
const key = keys[i];
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const objectKey = key;
|
|
27
|
+
const value = obj[objectKey];
|
|
28
|
+
if (!shouldOmit(value, key)) result[objectKey] = value;
|
|
28
29
|
}
|
|
29
30
|
return result;
|
|
30
31
|
}
|
package/dist/object/omitBy.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param obj - The object to omit properties from.
|
|
10
10
|
* @param shouldOmit - A predicate function that determines
|
|
11
11
|
* whether a property should be omitted. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be omitted, and `false` otherwise.
|
|
12
|
+
* if the property should be omitted, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
13
|
* @returns A new object with the properties that do not satisfy the predicate function.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
@@ -23,8 +23,9 @@ function omitBy(obj, shouldOmit) {
|
|
|
23
23
|
const keys = Object.keys(obj);
|
|
24
24
|
for (let i = 0; i < keys.length; i++) {
|
|
25
25
|
const key = keys[i];
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const objectKey = key;
|
|
27
|
+
const value = obj[objectKey];
|
|
28
|
+
if (!shouldOmit(value, key)) result[objectKey] = value;
|
|
28
29
|
}
|
|
29
30
|
return result;
|
|
30
31
|
}
|
package/dist/object/pickBy.d.mts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ObjectKeys } from "../types/ObjectKeys.mjs";
|
|
2
|
+
|
|
1
3
|
//#region src/object/pickBy.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Creates a new object composed of the properties that satisfy the predicate function.
|
|
@@ -9,7 +11,7 @@
|
|
|
9
11
|
* @param obj - The object to pick properties from.
|
|
10
12
|
* @param shouldPick - A predicate function that determines
|
|
11
13
|
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be picked, and `false` otherwise.
|
|
14
|
+
* if the property should be picked, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
15
|
* @returns A new object with the properties that satisfy the predicate function.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
@@ -18,6 +20,6 @@
|
|
|
18
20
|
* const result = pickBy(obj, shouldPick);
|
|
19
21
|
* // result will be { b: 'pick' }
|
|
20
22
|
*/
|
|
21
|
-
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key:
|
|
23
|
+
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: ObjectKeys<T>) => boolean): Partial<T>;
|
|
22
24
|
//#endregion
|
|
23
25
|
export { pickBy };
|
package/dist/object/pickBy.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ObjectKeys } from "../types/ObjectKeys.js";
|
|
2
|
+
|
|
1
3
|
//#region src/object/pickBy.d.ts
|
|
2
4
|
/**
|
|
3
5
|
* Creates a new object composed of the properties that satisfy the predicate function.
|
|
@@ -9,7 +11,7 @@
|
|
|
9
11
|
* @param obj - The object to pick properties from.
|
|
10
12
|
* @param shouldPick - A predicate function that determines
|
|
11
13
|
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be picked, and `false` otherwise.
|
|
14
|
+
* if the property should be picked, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
15
|
* @returns A new object with the properties that satisfy the predicate function.
|
|
14
16
|
*
|
|
15
17
|
* @example
|
|
@@ -18,6 +20,6 @@
|
|
|
18
20
|
* const result = pickBy(obj, shouldPick);
|
|
19
21
|
* // result will be { b: 'pick' }
|
|
20
22
|
*/
|
|
21
|
-
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key:
|
|
23
|
+
declare function pickBy<T extends Record<string, any>>(obj: T, shouldPick: (value: T[keyof T], key: ObjectKeys<T>) => boolean): Partial<T>;
|
|
22
24
|
//#endregion
|
|
23
25
|
export { pickBy };
|
package/dist/object/pickBy.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param obj - The object to pick properties from.
|
|
10
10
|
* @param shouldPick - A predicate function that determines
|
|
11
11
|
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be picked, and `false` otherwise.
|
|
12
|
+
* if the property should be picked, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
13
|
* @returns A new object with the properties that satisfy the predicate function.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
@@ -23,8 +23,9 @@ function pickBy(obj, shouldPick) {
|
|
|
23
23
|
const keys = Object.keys(obj);
|
|
24
24
|
for (let i = 0; i < keys.length; i++) {
|
|
25
25
|
const key = keys[i];
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const objectKey = key;
|
|
27
|
+
const value = obj[objectKey];
|
|
28
|
+
if (shouldPick(value, key)) result[objectKey] = value;
|
|
28
29
|
}
|
|
29
30
|
return result;
|
|
30
31
|
}
|
package/dist/object/pickBy.mjs
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* @param obj - The object to pick properties from.
|
|
10
10
|
* @param shouldPick - A predicate function that determines
|
|
11
11
|
* whether a property should be picked. It takes the property's key and value as arguments and returns `true`
|
|
12
|
-
* if the property should be picked, and `false` otherwise.
|
|
12
|
+
* if the property should be picked, and `false` otherwise. Numeric keys are passed as strings.
|
|
13
13
|
* @returns A new object with the properties that satisfy the predicate function.
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
@@ -23,8 +23,9 @@ function pickBy(obj, shouldPick) {
|
|
|
23
23
|
const keys = Object.keys(obj);
|
|
24
24
|
for (let i = 0; i < keys.length; i++) {
|
|
25
25
|
const key = keys[i];
|
|
26
|
-
const
|
|
27
|
-
|
|
26
|
+
const objectKey = key;
|
|
27
|
+
const value = obj[objectKey];
|
|
28
|
+
if (shouldPick(value, key)) result[objectKey] = value;
|
|
28
29
|
}
|
|
29
30
|
return result;
|
|
30
31
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/types/ObjectKeys.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a union of the keys of `T` as they are returned by `Object.keys`:
|
|
4
|
+
* numeric keys are converted to strings and symbol keys are excluded. The key-side
|
|
5
|
+
* counterpart to `ValueOf`.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The object type to read keys from.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* type Keys = ObjectKeys<{ a: number; 1: string }>;
|
|
11
|
+
* // => 'a' | '1'
|
|
12
|
+
*
|
|
13
|
+
* const obj = { a: 1, b: 2 };
|
|
14
|
+
* const keys = Object.keys(obj) as Array<ObjectKeys<typeof obj>>;
|
|
15
|
+
* // => Array<'a' | 'b'>
|
|
16
|
+
*/
|
|
17
|
+
type ObjectKeys<T> = `${Exclude<keyof T, symbol>}`;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ObjectKeys };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/types/ObjectKeys.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Creates a union of the keys of `T` as they are returned by `Object.keys`:
|
|
4
|
+
* numeric keys are converted to strings and symbol keys are excluded. The key-side
|
|
5
|
+
* counterpart to `ValueOf`.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The object type to read keys from.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* type Keys = ObjectKeys<{ a: number; 1: string }>;
|
|
11
|
+
* // => 'a' | '1'
|
|
12
|
+
*
|
|
13
|
+
* const obj = { a: 1, b: 2 };
|
|
14
|
+
* const keys = Object.keys(obj) as Array<ObjectKeys<typeof obj>>;
|
|
15
|
+
* // => Array<'a' | 'b'>
|
|
16
|
+
*/
|
|
17
|
+
type ObjectKeys<T> = `${Exclude<keyof T, symbol>}`;
|
|
18
|
+
//#endregion
|
|
19
|
+
export { ObjectKeys };
|
package/dist/types/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ObjectKeys } from "./ObjectKeys.mjs";
|
|
1
2
|
import { ToCamelCaseKeys } from "./ToCamelCaseKeys.mjs";
|
|
2
3
|
import { ToConstantCaseKeys } from "./ToConstantCaseKeys.mjs";
|
|
3
4
|
import { ToKebabCaseKeys } from "./ToKebabCaseKeys.mjs";
|
|
@@ -9,4 +10,4 @@ import { NonEmptyArray } from "./NonEmptyArray.mjs";
|
|
|
9
10
|
import { Simplify } from "./Simplify.mjs";
|
|
10
11
|
import { ValueOf } from "./ValueOf.mjs";
|
|
11
12
|
import { Writable } from "./Writable.mjs";
|
|
12
|
-
export { type DeepPartial, type DeepReadonly, type NonEmptyArray, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type ValueOf, type Writable };
|
|
13
|
+
export { type DeepPartial, type DeepReadonly, type NonEmptyArray, type ObjectKeys, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type ValueOf, type Writable };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ObjectKeys } from "./ObjectKeys.js";
|
|
1
2
|
import { ToCamelCaseKeys } from "./ToCamelCaseKeys.js";
|
|
2
3
|
import { ToConstantCaseKeys } from "./ToConstantCaseKeys.js";
|
|
3
4
|
import { ToKebabCaseKeys } from "./ToKebabCaseKeys.js";
|
|
@@ -9,4 +10,4 @@ import { NonEmptyArray } from "./NonEmptyArray.js";
|
|
|
9
10
|
import { Simplify } from "./Simplify.js";
|
|
10
11
|
import { ValueOf } from "./ValueOf.js";
|
|
11
12
|
import { Writable } from "./Writable.js";
|
|
12
|
-
export { type DeepPartial, type DeepReadonly, type NonEmptyArray, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type ValueOf, type Writable };
|
|
13
|
+
export { type DeepPartial, type DeepReadonly, type NonEmptyArray, type ObjectKeys, type Simplify, type ToCamelCaseKeys, type ToConstantCaseKeys, type ToKebabCaseKeys, type ToPascalCaseKeys, type ToSnakeCaseKeys, type ValueOf, type Writable };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
|
-
"version": "1.51.0-dev.
|
|
3
|
+
"version": "1.51.0-dev.2077+61705608",
|
|
4
4
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
5
5
|
"homepage": "https://es-toolkit.dev",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|