main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | import baseFor from './_baseFor.js';
|
---|
2 | import castFunction from './_castFunction.js';
|
---|
3 | import keysIn from './keysIn.js';
|
---|
4 |
|
---|
5 | /**
|
---|
6 | * Iterates over own and inherited enumerable string keyed properties of an
|
---|
7 | * object and invokes `iteratee` for each property. The iteratee is invoked
|
---|
8 | * with three arguments: (value, key, object). Iteratee functions may exit
|
---|
9 | * iteration early by explicitly returning `false`.
|
---|
10 | *
|
---|
11 | * @static
|
---|
12 | * @memberOf _
|
---|
13 | * @since 0.3.0
|
---|
14 | * @category Object
|
---|
15 | * @param {Object} object The object to iterate over.
|
---|
16 | * @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
---|
17 | * @returns {Object} Returns `object`.
|
---|
18 | * @see _.forInRight
|
---|
19 | * @example
|
---|
20 | *
|
---|
21 | * function Foo() {
|
---|
22 | * this.a = 1;
|
---|
23 | * this.b = 2;
|
---|
24 | * }
|
---|
25 | *
|
---|
26 | * Foo.prototype.c = 3;
|
---|
27 | *
|
---|
28 | * _.forIn(new Foo, function(value, key) {
|
---|
29 | * console.log(key);
|
---|
30 | * });
|
---|
31 | * // => Logs 'a', 'b', then 'c' (iteration order is not guaranteed).
|
---|
32 | */
|
---|
33 | function forIn(object, iteratee) {
|
---|
34 | return object == null
|
---|
35 | ? object
|
---|
36 | : baseFor(object, castFunction(iteratee), keysIn);
|
---|
37 | }
|
---|
38 |
|
---|
39 | export default forIn;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.