Travis build: 1306
This commit is contained in:
67
README.md
67
README.md
@ -275,6 +275,7 @@ average(1, 2, 3);
|
|||||||
* [`cleanObj`](#cleanobj)
|
* [`cleanObj`](#cleanobj)
|
||||||
* [`equals`](#equals-)
|
* [`equals`](#equals-)
|
||||||
* [`functions`](#functions)
|
* [`functions`](#functions)
|
||||||
|
* [`get`](#get)
|
||||||
* [`invertKeyValues`](#invertkeyvalues)
|
* [`invertKeyValues`](#invertkeyvalues)
|
||||||
* [`lowercaseKeys`](#lowercasekeys)
|
* [`lowercaseKeys`](#lowercasekeys)
|
||||||
* [`mapKeys`](#mapkeys)
|
* [`mapKeys`](#mapkeys)
|
||||||
@ -371,15 +372,6 @@ average(1, 2, 3);
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### _Uncategorized_
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>View contents</summary>
|
|
||||||
|
|
||||||
* [`get`](#get)
|
|
||||||
|
|
||||||
</details>
|
|
||||||
|
|
||||||
---
|
---
|
||||||
## 🔌 Adapter
|
## 🔌 Adapter
|
||||||
|
|
||||||
@ -4263,6 +4255,36 @@ functions(new Foo(), true); // ['a', 'b', 'c']
|
|||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
|
### get
|
||||||
|
|
||||||
|
Retrieve a set of properties indicated by the given selectors from an object.
|
||||||
|
|
||||||
|
Use `Array.map()` for each selector, `String.replace()` to replace square brackets with dots, `String.split('.')` to split each selector, `Array.filter()` to remove empty values and `Array.reduce()` to get the value indicated by it.
|
||||||
|
|
||||||
|
```js
|
||||||
|
const get = (from, ...selectors) =>
|
||||||
|
[...selectors].map(s =>
|
||||||
|
s
|
||||||
|
.replace(/\[([^\[\]]*)\]/g, '.$1.')
|
||||||
|
.split('.')
|
||||||
|
.filter(t => t !== '')
|
||||||
|
.reduce((prev, cur) => prev && prev[cur], from)
|
||||||
|
);
|
||||||
|
```
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>Examples</summary>
|
||||||
|
|
||||||
|
```js
|
||||||
|
const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, { a: 'test' }] };
|
||||||
|
get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1, 'test']
|
||||||
|
```
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
|
|
||||||
### invertKeyValues
|
### invertKeyValues
|
||||||
|
|
||||||
Inverts the key-value pairs of an object, without mutating it.
|
Inverts the key-value pairs of an object, without mutating it.
|
||||||
@ -6183,33 +6205,6 @@ yesNo('Foo', true); // true
|
|||||||
|
|
||||||
<br>[⬆ Back to top](#table-of-contents)
|
<br>[⬆ Back to top](#table-of-contents)
|
||||||
|
|
||||||
---
|
|
||||||
## _Uncategorized_
|
|
||||||
|
|
||||||
### get
|
|
||||||
|
|
||||||
Retrieve a set of properties indicated by the given selectors from an object.
|
|
||||||
|
|
||||||
Use `Array.map()` for each selector, `String.replace()` to replace square brackets with dots, `String.split('.')` to split each selector, `Array.filter()` to remove empty values and `Array.reduce()` to get the value indicated by it.
|
|
||||||
|
|
||||||
```js
|
|
||||||
const get = (from, ...selectors) =>
|
|
||||||
[...selectors].map(s =>
|
|
||||||
s
|
|
||||||
.replace(/\[([^\[\]]*)\]/g, '.$1.')
|
|
||||||
.split('.')
|
|
||||||
.filter(t => t !== '')
|
|
||||||
.reduce((prev, cur) => prev && prev[cur], from)
|
|
||||||
);
|
|
||||||
```
|
|
||||||
|
|
||||||
```js
|
|
||||||
const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, { a: 'test' }] };
|
|
||||||
get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1, 'test']
|
|
||||||
```
|
|
||||||
|
|
||||||
<br>[⬆ back to top](#table-of-contents)
|
|
||||||
|
|
||||||
|
|
||||||
## Collaborators
|
## Collaborators
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user