Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
breeze2 committed Jul 26, 2019
1 parent d016e40 commit 225716c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion README.md
Expand Up @@ -25,11 +25,30 @@ function task (url) {

const throttleTask = AsyncTaskThrottle.create(task, 6, 100)

// use throttleTask like task
// use `throttleTask` just like `task`
// but up to 6 tasks are running at the same moment
throttleTask('https://github.com/breeze2/markdown-it-all').then(value => {
console.log(value)
}).catch(error => {
console.error(error)
})

```

### Interface

#### AsyncTaskThrottle.create

```js
function AsyncTaskThrottle.create(
task: T extends (...args: any[]) => Promise<any>,
size?: number = 6,
max: number = Infinity
): T

```

* task: the async task function.
* size: defualt 6, at the same moment, up to `size` tasks are runing, others are in the waiting queue.
* max: defualt Infinity, when the length of waiting queue is greater than `max`, late tasks will be rejected instantly.

0 comments on commit 225716c

Please sign in to comment.