Travis build: 1192
This commit is contained in:
12
README.md
12
README.md
@@ -4054,13 +4054,13 @@ orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', a
|
||||
|
||||
### select
|
||||
|
||||
Retrieve a property indicated by the selector from an object.
|
||||
Retrieve a set of properties indicated by the given selectors from an object.
|
||||
|
||||
If the property does not exists returns `undefined`.
|
||||
Use `Array.map()` for each selector, `String.split('.')` to split each selector and `Array.reduce()` to get the value indicated by it.
|
||||
|
||||
```js
|
||||
const select = (from, selector) =>
|
||||
selector.split('.').reduce((prev, cur) => prev && prev[cur], from);
|
||||
const select = (from, ...selectors) =>
|
||||
[...selectors].map(s => s.split('.').reduce((prev, cur) => prev && prev[cur], from));
|
||||
```
|
||||
|
||||
<details>
|
||||
@@ -4068,7 +4068,8 @@ const select = (from, selector) =>
|
||||
|
||||
```js
|
||||
const obj = { selector: { to: { val: 'val to select' } } };
|
||||
select(obj, 'selector.to.val'); // 'val to select'
|
||||
select(obj, 'selector.to.val'); // ['val to select']
|
||||
select(obj, 'selector.to.val', 'selector.to'); // ['val to select', { val: 'val to select' }]
|
||||
```
|
||||
|
||||
</details>
|
||||
@@ -5364,6 +5365,7 @@ const httpPost = (url, callback, data = null, err = console.error) => {
|
||||
|
||||
|
||||
|
||||
|
||||
const newPost = {
|
||||
"userId": 1,
|
||||
"id": 1337,
|
||||
|
||||
Reference in New Issue
Block a user