Skip to content

Commit c14fa03

Browse files
author
Chu Fan
committed
chore: 清理manuscripts手稿目录
1 parent 28d3738 commit c14fa03

30 files changed

+79
-2
lines changed

code/node/lodash/deme-array.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const _ = require('lodash')
2+
3+
// chunk() 数组分片
4+
_.chunk(['a', 'b', 'c', 'd'], 2)
5+
// => [['a', 'b'], ['c', 'd']]
6+
7+
_.chunk(['a', 'b', 'c', 'd'], 3)
8+
// => [['a', 'b', 'c'], ['d']]
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
# ES6
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
2+
# Lodash
3+
4+
- 官网:<https://www.lodashjs.com>
5+
6+
Lodash 是一个一致性、模块化、高性能的 JavaScript 实用工具库, 通过降低 array、number、objects、string 等等的使用难度从而让 JavaScript 变得更简单。 Lodash 的模块化方法 非常适用于:
7+
8+
- 遍历 array、object 和 string
9+
- 对值进行操作和检测
10+
- 创建符合功能的函数
11+
12+
### 安装
13+
14+
```bash
15+
## 全局安装
16+
npm i -g npm
17+
## 生产环境安装
18+
npm i --save lodash
19+
20+
```
21+
22+
### 使用
23+
24+
```js
25+
const _ =require('lodash')
26+
27+
_.chunk(['a', 'b', 'c', 'd'], 2);
28+
// => [['a', 'b'], ['c', 'd']]
29+
30+
_.chunk(['a', 'b', 'c', 'd'], 3);
31+
// => [['a', 'b', 'c'], ['d']]
32+
33+
34+
```
35+
36+
### 数组
37+
38+
#### 分片(chunk)
39+
40+
将数组(array)拆分成多个 size 长度的区块,并将这些区块组成一个新数组。 如果array 无法被分割成全部等长的区块,那么最后剩余的元素将组成一个区块。
41+
42+
格式:` _.chunk(array, [size=1])`
43+
44+
参数:
45+
46+
- array (Array): 需要处理的数组
47+
- [size=1] (number): 每个数组区块的长度
48+
49+
返回:返回一个包含拆分区块的新数组(即:二维数组)
50+
51+
实际使用:
52+
53+
```js
54+
_.chunk(['a', 'b', 'c', 'd'], 2);
55+
// => [['a', 'b'], ['c', 'd']]
56+
57+
_.chunk(['a', 'b', 'c', 'd'], 3);
58+
// => [['a', 'b', 'c'], ['d']]
59+
60+
```
61+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11

22

3-
## Node.js
3+
# Node.js

docs/manuscript/server-end/server-end.sidebar.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,11 @@ export const serverEndSidebar = [
1919
{
2020
text: 'dayjs',
2121
link: 'node-learn/dayjs.md'
22+
},
23+
{
24+
text: 'lodash',
25+
link: 'node-learn/lodash.md'
2226
}
23-
2427
]
2528
},
2629
{
-54.9 KB
Binary file not shown.
-105 KB
Binary file not shown.
-22 KB
Binary file not shown.
-12.9 KB
Binary file not shown.
-25.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)