Travis build: 1304
This commit is contained in:
62
README.md
62
README.md
@ -283,7 +283,6 @@ average(1, 2, 3);
|
|||||||
* [`objectFromPairs`](#objectfrompairs)
|
* [`objectFromPairs`](#objectfrompairs)
|
||||||
* [`objectToPairs`](#objecttopairs)
|
* [`objectToPairs`](#objecttopairs)
|
||||||
* [`orderBy`](#orderby)
|
* [`orderBy`](#orderby)
|
||||||
* [`select`](#select)
|
|
||||||
* [`shallowClone`](#shallowclone)
|
* [`shallowClone`](#shallowclone)
|
||||||
* [`size`](#size)
|
* [`size`](#size)
|
||||||
* [`transform`](#transform)
|
* [`transform`](#transform)
|
||||||
@ -372,6 +371,15 @@ average(1, 2, 3);
|
|||||||
|
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
|
### _Uncategorized_
|
||||||
|
|
||||||
|
<details>
|
||||||
|
<summary>View contents</summary>
|
||||||
|
|
||||||
|
* [`get`](#get)
|
||||||
|
|
||||||
|
</details>
|
||||||
|
|
||||||
---
|
---
|
||||||
## 🔌 Adapter
|
## 🔌 Adapter
|
||||||
|
|
||||||
@ -4485,31 +4493,6 @@ 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)
|
||||||
|
|
||||||
|
|
||||||
### select
|
|
||||||
|
|
||||||
Retrieve a set of properties indicated by the given selectors from an object.
|
|
||||||
|
|
||||||
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, ...selectors) =>
|
|
||||||
[...selectors].map(s => s.split('.').reduce((prev, cur) => prev && prev[cur], from));
|
|
||||||
```
|
|
||||||
|
|
||||||
<details>
|
|
||||||
<summary>Examples</summary>
|
|
||||||
|
|
||||||
```js
|
|
||||||
const 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>
|
|
||||||
|
|
||||||
<br>[⬆ Back to top](#table-of-contents)
|
|
||||||
|
|
||||||
|
|
||||||
### shallowClone
|
### shallowClone
|
||||||
|
|
||||||
Creates a shallow clone of an object.
|
Creates a shallow clone of an object.
|
||||||
@ -6200,6 +6183,33 @@ 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
@ -57,6 +57,7 @@ functionName:function,utility
|
|||||||
functions:object,function
|
functions:object,function
|
||||||
gcd:math,recursion
|
gcd:math,recursion
|
||||||
geometricProgression:math
|
geometricProgression:math
|
||||||
|
get:uncategorized
|
||||||
getDaysDiffBetweenDates:date
|
getDaysDiffBetweenDates:date
|
||||||
getScrollPosition:browser
|
getScrollPosition:browser
|
||||||
getStyle:browser,css
|
getStyle:browser,css
|
||||||
@ -164,7 +165,6 @@ sample:array,random
|
|||||||
sampleSize:array,random
|
sampleSize:array,random
|
||||||
scrollToTop:browser
|
scrollToTop:browser
|
||||||
sdbm:math,utility
|
sdbm:math,utility
|
||||||
select:object
|
|
||||||
serializeCookie:utility,string
|
serializeCookie:utility,string
|
||||||
setStyle:browser
|
setStyle:browser
|
||||||
shallowClone:object
|
shallowClone:object
|
||||||
|
|||||||
Reference in New Issue
Block a user