From 54a357c7aaa41b59aae239d49267ca204330913a Mon Sep 17 00:00:00 2001 From: xuwu Date: Wed, 17 Mar 2021 08:24:36 +0800 Subject: [PATCH] docs: update readme --- README.md | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/README.md b/README.md index 3f62227..62b23bd 100644 --- a/README.md +++ b/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) +
+ ```js const dedup = (data, getKey = () => {} ) => { // todo @@ -57,6 +91,8 @@ let data1 = [ // ]; ``` +
+ 第六题:[实现一个 chunk 函数](https://github.com/KieSun/fucking-frontend/issues/8)