Travis build: 1310
This commit is contained in:
49
README.md
49
README.md
@ -274,6 +274,8 @@ average(1, 2, 3);
|
||||
|
||||
* [`cleanObj`](#cleanobj)
|
||||
* [`equals`](#equals-)
|
||||
* [`forOwn`](#forown)
|
||||
* [`forOwnRight`](#forownright)
|
||||
* [`functions`](#functions)
|
||||
* [`get`](#get)
|
||||
* [`invertKeyValues`](#invertkeyvalues)
|
||||
@ -4220,6 +4222,53 @@ equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'f
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### forOwn
|
||||
|
||||
Iterates over all own properties of an object, running a callback for each one.
|
||||
|
||||
Use `Object.keys(obj)` to get all the properties of the object, `Array.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.
|
||||
|
||||
```js
|
||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### forOwnRight
|
||||
|
||||
Iterates over all own properties of an object in reverse, running a callback for each one.
|
||||
|
||||
Use `Object.keys(obj)` to get all the properties of the object, `Array.reverse()` to reverse their order and `Array.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.
|
||||
|
||||
```js
|
||||
const forOwnRight = (obj, fn) =>
|
||||
Object.keys(obj)
|
||||
.reverse()
|
||||
.forEach(key => fn(obj[key], key, obj));
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>Examples</summary>
|
||||
|
||||
```js
|
||||
forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar'
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
<br>[⬆ Back to top](#table-of-contents)
|
||||
|
||||
|
||||
### functions
|
||||
|
||||
Returns an array of function property names from own (and optionally inherited) enumerable properties of an object.
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -5,9 +5,9 @@ Iterates over all own properties of an object, running a callback for each one.
|
||||
Use `Object.keys(obj)` to get all the properties of the object, `Array.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.
|
||||
|
||||
```js
|
||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key],key,obj));
|
||||
const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj));
|
||||
```
|
||||
|
||||
```js
|
||||
forOwn({foo: 'bar', a: 1}, v => console.log(v)); // 'bar', 1
|
||||
forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1
|
||||
```
|
||||
|
||||
@ -5,9 +5,12 @@ Iterates over all own properties of an object in reverse, running a callback for
|
||||
Use `Object.keys(obj)` to get all the properties of the object, `Array.reverse()` to reverse their order and `Array.forEach()` to run the provided function for each key-value pair. The callback receives three arguments - the value, the key and the object.
|
||||
|
||||
```js
|
||||
const forOwnRight = (obj, fn) => Object.keys(obj).reverse().forEach(key => fn(obj[key],key,obj));
|
||||
const forOwnRight = (obj, fn) =>
|
||||
Object.keys(obj)
|
||||
.reverse()
|
||||
.forEach(key => fn(obj[key], key, obj));
|
||||
```
|
||||
|
||||
```js
|
||||
forOwnRight({foo: 'bar', a: 1}, v => console.log(v)); // 1, 'bar'
|
||||
forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar'
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user