Last change
on this file since 6fe77af was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Line | |
---|
1 | var baseFor = require('./_baseFor'),
|
---|
2 | castFunction = require('./_castFunction'),
|
---|
3 | keysIn = require('./keysIn');
|
---|
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 | module.exports = forIn;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.