es-toolkit 1.35.0-dev.1178 → 1.35.0-dev.1179
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/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.d.mts +1 -0
- package/dist/compat/index.d.ts +1 -0
- package/dist/compat/index.js +16 -0
- package/dist/compat/index.mjs +1 -0
- package/dist/compat/object/forOwn.d.mts +26 -0
- package/dist/compat/object/forOwn.d.ts +26 -0
- package/dist/compat/object/forOwn.mjs +19 -0
- package/package.json +1 -1
package/dist/compat/index.d.mts
CHANGED
|
@@ -184,6 +184,7 @@ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
|
|
|
184
184
|
export { create } from './object/create.mjs';
|
|
185
185
|
export { defaults } from './object/defaults.mjs';
|
|
186
186
|
export { findKey } from './object/findKey.mjs';
|
|
187
|
+
export { forOwn } from './object/forOwn.mjs';
|
|
187
188
|
export { fromPairs } from './object/fromPairs.mjs';
|
|
188
189
|
export { functions } from './object/functions.mjs';
|
|
189
190
|
export { functionsIn } from './object/functionsIn.mjs';
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -184,6 +184,7 @@ export { cloneDeepWith } from './object/cloneDeepWith.js';
|
|
|
184
184
|
export { create } from './object/create.js';
|
|
185
185
|
export { defaults } from './object/defaults.js';
|
|
186
186
|
export { findKey } from './object/findKey.js';
|
|
187
|
+
export { forOwn } from './object/forOwn.js';
|
|
187
188
|
export { fromPairs } from './object/fromPairs.js';
|
|
188
189
|
export { functions } from './object/functions.js';
|
|
189
190
|
export { functionsIn } from './object/functionsIn.js';
|
package/dist/compat/index.js
CHANGED
|
@@ -2571,6 +2571,21 @@ function findKeyImpl(obj, predicate) {
|
|
|
2571
2571
|
}
|
|
2572
2572
|
}
|
|
2573
2573
|
|
|
2574
|
+
function forOwn(object, iteratee = unary.identity) {
|
|
2575
|
+
if (!object) {
|
|
2576
|
+
return object;
|
|
2577
|
+
}
|
|
2578
|
+
const iterable = Object(object);
|
|
2579
|
+
const keys$1 = keys(object);
|
|
2580
|
+
for (let i = 0; i < keys$1.length; ++i) {
|
|
2581
|
+
const key = keys$1[i];
|
|
2582
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
2583
|
+
break;
|
|
2584
|
+
}
|
|
2585
|
+
}
|
|
2586
|
+
return object;
|
|
2587
|
+
}
|
|
2588
|
+
|
|
2574
2589
|
function fromPairs(pairs) {
|
|
2575
2590
|
if (!isArrayLike(pairs) && !(pairs instanceof Map)) {
|
|
2576
2591
|
return {};
|
|
@@ -3734,6 +3749,7 @@ exports.floor = floor;
|
|
|
3734
3749
|
exports.flow = flow;
|
|
3735
3750
|
exports.flowRight = flowRight;
|
|
3736
3751
|
exports.forEach = forEach;
|
|
3752
|
+
exports.forOwn = forOwn;
|
|
3737
3753
|
exports.fromPairs = fromPairs;
|
|
3738
3754
|
exports.functions = functions;
|
|
3739
3755
|
exports.functionsIn = functionsIn;
|
package/dist/compat/index.mjs
CHANGED
|
@@ -186,6 +186,7 @@ export { cloneDeepWith } from './object/cloneDeepWith.mjs';
|
|
|
186
186
|
export { create } from './object/create.mjs';
|
|
187
187
|
export { defaults } from './object/defaults.mjs';
|
|
188
188
|
export { findKey } from './object/findKey.mjs';
|
|
189
|
+
export { forOwn } from './object/forOwn.mjs';
|
|
189
190
|
export { fromPairs } from './object/fromPairs.mjs';
|
|
190
191
|
export { functions } from './object/functions.mjs';
|
|
191
192
|
export { functionsIn } from './object/functionsIn.mjs';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterates over own enumerable properties of an object invoking iteratee for each property. The iteratee is
|
|
3
|
+
* invoked with three arguments: (value, key, object). Iteratee functions may exit
|
|
4
|
+
* iteration early by explicitly returning false.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the object.
|
|
7
|
+
* @param {T | null | undefined} object The object to iterate over.
|
|
8
|
+
* @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
|
|
9
|
+
* @return {T | null | undefined} Returns object.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* function Foo() {
|
|
13
|
+
* this.a = 1;
|
|
14
|
+
* this.b = 2;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* Foo.prototype.c = 3;
|
|
18
|
+
*
|
|
19
|
+
* forOwn(new Foo(), function(value, key) {
|
|
20
|
+
* console.log(key);
|
|
21
|
+
* });
|
|
22
|
+
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
|
23
|
+
*/
|
|
24
|
+
declare function forOwn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
|
|
25
|
+
|
|
26
|
+
export { forOwn };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Iterates over own enumerable properties of an object invoking iteratee for each property. The iteratee is
|
|
3
|
+
* invoked with three arguments: (value, key, object). Iteratee functions may exit
|
|
4
|
+
* iteration early by explicitly returning false.
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the object.
|
|
7
|
+
* @param {T | null | undefined} object The object to iterate over.
|
|
8
|
+
* @param {(value: T[keyof T], key: string, collection: T) => any} [iteratee=identity] The function invoked per iteration. If not provided, the identity function will be used.
|
|
9
|
+
* @return {T | null | undefined} Returns object.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* function Foo() {
|
|
13
|
+
* this.a = 1;
|
|
14
|
+
* this.b = 2;
|
|
15
|
+
* }
|
|
16
|
+
*
|
|
17
|
+
* Foo.prototype.c = 3;
|
|
18
|
+
*
|
|
19
|
+
* forOwn(new Foo(), function(value, key) {
|
|
20
|
+
* console.log(key);
|
|
21
|
+
* });
|
|
22
|
+
* // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
|
23
|
+
*/
|
|
24
|
+
declare function forOwn<T>(object: T | null | undefined, iteratee?: (value: T[keyof T], key: string, collection: T) => any): T | null | undefined;
|
|
25
|
+
|
|
26
|
+
export { forOwn };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { keys } from './keys.mjs';
|
|
2
|
+
import { identity } from '../../function/identity.mjs';
|
|
3
|
+
|
|
4
|
+
function forOwn(object, iteratee = identity) {
|
|
5
|
+
if (!object) {
|
|
6
|
+
return object;
|
|
7
|
+
}
|
|
8
|
+
const iterable = Object(object);
|
|
9
|
+
const keys$1 = keys(object);
|
|
10
|
+
for (let i = 0; i < keys$1.length; ++i) {
|
|
11
|
+
const key = keys$1[i];
|
|
12
|
+
if (iteratee(iterable[key], key, iterable) === false) {
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return object;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { forOwn };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-toolkit",
|
|
3
3
|
"description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
|
|
4
|
-
"version": "1.35.0-dev.
|
|
4
|
+
"version": "1.35.0-dev.1179+43e66957",
|
|
5
5
|
"homepage": "https://es-toolkit.slash.page",
|
|
6
6
|
"bugs": "https://github.com/toss/es-toolkit/issues",
|
|
7
7
|
"repository": {
|