Update
This commit is contained in:
parent
f7c9650a56
commit
0b6df688d7
|
@ -35,6 +35,7 @@ defaults:
|
||||||
layout: "default"
|
layout: "default"
|
||||||
type: article
|
type: article
|
||||||
category: "Others"
|
category: "Others"
|
||||||
|
excerpt_separator: "<!--more-->"
|
||||||
|
|
||||||
# Site info
|
# Site info
|
||||||
url: http://ricostacruz.com/cheatsheets
|
url: http://ricostacruz.com/cheatsheets
|
||||||
|
|
25
lodash.md
25
lodash.md
|
@ -1,13 +1,17 @@
|
||||||
---
|
---
|
||||||
title: Lodash
|
title: Lodash
|
||||||
category: JavaScript libraries
|
category: JavaScript libraries
|
||||||
|
layout: 2017/sheet
|
||||||
|
weight: -3
|
||||||
---
|
---
|
||||||
|
|
||||||
> This is an incomplete list.
|
This is not a complete list.
|
||||||
|
|
||||||
|
<!--more-->
|
||||||
|
|
||||||
## Collections
|
## Collections
|
||||||
|
|
||||||
Works for both arrays and objects.
|
### Finding
|
||||||
|
|
||||||
```js
|
```js
|
||||||
_.filter(list, (n) => n % 2) //=> Array
|
_.filter(list, (n) => n % 2) //=> Array
|
||||||
|
@ -15,6 +19,8 @@ _.find(list, (n) => n % 2) //=> item
|
||||||
_.findRight(list, ...) //=> item
|
_.findRight(list, ...) //=> item
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Works for both arrays and objects.
|
||||||
|
|
||||||
### Accessing
|
### Accessing
|
||||||
|
|
||||||
```js
|
```js
|
||||||
|
@ -46,6 +52,8 @@ _.any(users, ...) //=> true|false (aka _.some)
|
||||||
|
|
||||||
## Array
|
## Array
|
||||||
|
|
||||||
|
### Arrays
|
||||||
|
|
||||||
```js
|
```js
|
||||||
_.chunk([ abcd ], 2) //=> [ [ab], [cd] ]
|
_.chunk([ abcd ], 2) //=> [ [ab], [cd] ]
|
||||||
_.compact(list)
|
_.compact(list)
|
||||||
|
@ -62,20 +70,27 @@ _.drop([ abcdef ], 2) //=> [ cdef ]
|
||||||
_.dropRight([ abcdef ], 2) //=> [ abcd ]
|
_.dropRight([ abcdef ], 2) //=> [ abcd ]
|
||||||
_.take([ abcdef ], 2) //=> [ ab ]
|
_.take([ abcdef ], 2) //=> [ ab ]
|
||||||
_.takeRight([ abcdef ], 2) //=> [ de ]
|
_.takeRight([ abcdef ], 2) //=> [ de ]
|
||||||
|
_.slice([ abcdef ], 2, 4) //=> [ cd ]
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
_.initial([ abcdef ]) //=> [ abcde ] - dropRight(list, 1)
|
_.initial([ abcdef ]) //=> [ abcde ] - dropRight(list, 1)
|
||||||
_.rest([ abcdef ]) //=> [ bcdef ] - takeRight(list, 1)
|
_.rest([ abcdef ]) //=> [ bcdef ] - takeRight(list, 1)
|
||||||
|
```
|
||||||
|
|
||||||
_.slice([ abcdef ], 2, 4) //=> [ cd ]
|
```js
|
||||||
|
|
||||||
_.dropWhile(list, 'active') // works like filter
|
_.dropWhile(list, 'active') // works like filter
|
||||||
_.dropWhile(list, 'active', true)
|
_.dropWhile(list, 'active', true)
|
||||||
_.dropWhile(list, { active: true })
|
_.dropWhile(list, { active: true })
|
||||||
_.dropWhile(list, (n) => ...)
|
_.dropWhile(list, (n) => ...)
|
||||||
_.dropRightWhile(list, ...)
|
_.dropRightWhile(list, ...)
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
_.without([ abcde ], b) //=> [ acde ]
|
_.without([ abcde ], b) //=> [ acde ]
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
_.remove(list, (n) => n % 2)
|
_.remove(list, (n) => n % 2)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -130,7 +145,7 @@ _.curry(greet)('hi') //=> function(name)
|
||||||
_.curryRight(greet)('joe') //=> function(greet)
|
_.curryRight(greet)('joe') //=> function(greet)
|
||||||
```
|
```
|
||||||
|
|
||||||
## Functions - decorating
|
## Decorating functions
|
||||||
|
|
||||||
### Throttling
|
### Throttling
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue