Travis build: 1315
This commit is contained in:
75
README.md
75
README.md
@ -123,7 +123,6 @@ average(1, 2, 3);
|
|||||||
* [`minN`](#minn)
|
* [`minN`](#minn)
|
||||||
* [`nthElement`](#nthelement)
|
* [`nthElement`](#nthelement)
|
||||||
* [`partition`](#partition)
|
* [`partition`](#partition)
|
||||||
* [`pick`](#pick)
|
|
||||||
* [`pull`](#pull)
|
* [`pull`](#pull)
|
||||||
* [`pullAtIndex`](#pullatindex)
|
* [`pullAtIndex`](#pullatindex)
|
||||||
* [`pullAtValue`](#pullatvalue)
|
* [`pullAtValue`](#pullatvalue)
|
||||||
@ -284,7 +283,9 @@ average(1, 2, 3);
|
|||||||
* [`merge`](#merge)
|
* [`merge`](#merge)
|
||||||
* [`objectFromPairs`](#objectfrompairs)
|
* [`objectFromPairs`](#objectfrompairs)
|
||||||
* [`objectToPairs`](#objecttopairs)
|
* [`objectToPairs`](#objecttopairs)
|
||||||
|
* [`omit`](#omit)
|
||||||
* [`orderBy`](#orderby)
|
* [`orderBy`](#orderby)
|
||||||
|
* [`pick`](#pick)
|
||||||
* [`shallowClone`](#shallowclone)
|
* [`shallowClone`](#shallowclone)
|
||||||
* [`size`](#size)
|
* [`size`](#size)
|
||||||
* [`transform`](#transform)
|
* [`transform`](#transform)
|
||||||
@ -1349,29 +1350,6 @@ partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active':
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### pick
|
|
||||||
|
|
||||||
Picks the key-value pairs corresponding to the given keys from an object.
|
|
||||||
|
|
||||||
Use `Array.reduce()` to convert the filtered/picked keys back to an object with the corresponding key-value pair if the key exists in the obj.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const pick = (obj, arr) =>
|
|
||||||
arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
|
|
||||||
```
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Examples</summary>
|
|
||||||
|
|
||||||
```js
|
|
||||||
pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 }
|
|
||||||
```
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
<br>[⬆ Back to top](#table-of-contents)
|
|
||||||
|
|
||||||
|
|
||||||
### pull
|
### pull
|
||||||
|
|
||||||
Mutates the original array to filter out the values specified.
|
Mutates the original array to filter out the values specified.
|
||||||
@ -4496,6 +4474,32 @@ objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]]
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### omit
|
||||||
|
|
||||||
|
Omits the key-value pairs corresponding to the given keys from an object.
|
||||||
|
|
||||||
|
Use `Object.keys(obj)`, `Array.filter()` and `Array.includes()` to remove the provided keys.
|
||||||
|
Use `Array.reduce()` to convert the filtered keys back to an object with the corresponding key-value pairs.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const omit = (obj, arr) =>
|
||||||
|
Object.keys(obj)
|
||||||
|
.filter(k => !arr.includes(k))
|
||||||
|
.reduce((acc, key) => ((acc[key] = obj[key]), acc), {});
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 }
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### orderBy
|
### orderBy
|
||||||
|
|
||||||
Returns a sorted array of objects ordered by properties and orders.
|
Returns a sorted array of objects ordered by properties and orders.
|
||||||
@ -4530,6 +4534,29 @@ orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', a
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### pick
|
||||||
|
|
||||||
|
Picks the key-value pairs corresponding to the given keys from an object.
|
||||||
|
|
||||||
|
Use `Array.reduce()` to convert the filtered/picked keys back to an object with the corresponding key-value pairs if the key exists in the object.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const pick = (obj, arr) =>
|
||||||
|
arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {});
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 }
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### shallowClone
|
### shallowClone
|
||||||
|
|
||||||
Creates a shallow clone of an object.
|
Creates a shallow clone of an object.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user