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:
992 bytes
|
Rev | Line | |
---|
[6a3a178] | 1 | var baseForOwn = require('./_baseForOwn'),
|
---|
| 2 | castFunction = require('./_castFunction');
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Iterates over own enumerable string keyed properties of an object and
|
---|
| 6 | * invokes `iteratee` for each property. The iteratee is invoked with three
|
---|
| 7 | * arguments: (value, key, object). Iteratee functions may exit iteration
|
---|
| 8 | * early by explicitly returning `false`.
|
---|
| 9 | *
|
---|
| 10 | * @static
|
---|
| 11 | * @memberOf _
|
---|
| 12 | * @since 0.3.0
|
---|
| 13 | * @category Object
|
---|
| 14 | * @param {Object} object The object to iterate over.
|
---|
| 15 | * @param {Function} [iteratee=_.identity] The function invoked per iteration.
|
---|
| 16 | * @returns {Object} Returns `object`.
|
---|
| 17 | * @see _.forOwnRight
|
---|
| 18 | * @example
|
---|
| 19 | *
|
---|
| 20 | * function Foo() {
|
---|
| 21 | * this.a = 1;
|
---|
| 22 | * this.b = 2;
|
---|
| 23 | * }
|
---|
| 24 | *
|
---|
| 25 | * Foo.prototype.c = 3;
|
---|
| 26 | *
|
---|
| 27 | * _.forOwn(new Foo, function(value, key) {
|
---|
| 28 | * console.log(key);
|
---|
| 29 | * });
|
---|
| 30 | * // => Logs 'a' then 'b' (iteration order is not guaranteed).
|
---|
| 31 | */
|
---|
| 32 | function forOwn(object, iteratee) {
|
---|
| 33 | return object && baseForOwn(object, castFunction(iteratee));
|
---|
| 34 | }
|
---|
| 35 |
|
---|
| 36 | module.exports = forOwn;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.