mirror of
https://github.com/KieSun/all-of-frontend.git
synced 2024-12-12 09:54:36 +08:00
docs: update readme
This commit is contained in:
parent
bd79738767
commit
54a357c7aa
36
README.md
36
README.md
@ -26,8 +26,42 @@
|
||||
|
||||
### 今日原题
|
||||
|
||||
第八题:[对一个很长的名字数组,做分片更新名字请求](https://github.com/KieSun/fucking-frontend/issues/13)
|
||||
|
||||
```js
|
||||
/*
|
||||
* 对一个很长的名字数组,做分片更新名字请求:
|
||||
* 1. 分片里的更新是并行的,执行 changeName
|
||||
* 2. 各个分片间是串行的,执行 sleep
|
||||
* 这个函数接受三个参数,名字列表、分片数量,每次分片后的等待时间
|
||||
* 比如:
|
||||
* slicePostTask(['aa', 'bb', 'cc', 'dd', 'ee', 'ff', 'gg', 'hh'], 2, 2000)
|
||||
* // => ['aa', 'bb']
|
||||
* waiting 2s
|
||||
* // => ['cc', 'dd']
|
||||
* waiting 2s
|
||||
* // => ['ee', 'ff']
|
||||
* waiting 2s
|
||||
* // => ['gg', 'hh']
|
||||
*/
|
||||
|
||||
const changeName = (name) => new Promise((resolve, reject) => {
|
||||
setTimeout(() => resolve(name), 1000)
|
||||
})
|
||||
|
||||
const sleep = time => new Promise((resolve, reject) => {
|
||||
setTimeout(resolve, time)
|
||||
})
|
||||
|
||||
const slicePostTask = async (names, chunkSize, time) => {
|
||||
// todo
|
||||
}
|
||||
```
|
||||
|
||||
第七题:[数据排重](https://github.com/KieSun/fucking-frontend/issues/11)
|
||||
|
||||
<details>
|
||||
|
||||
```js
|
||||
const dedup = (data, getKey = () => {} ) => {
|
||||
// todo
|
||||
@ -57,6 +91,8 @@ let data1 = [
|
||||
// ];
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
第六题:[实现一个 chunk 函数](https://github.com/KieSun/fucking-frontend/issues/8)
|
||||
|
||||
<details>
|
||||
|
Loading…
Reference in New Issue
Block a user