1.1.4 • Published 6 years ago

async-queueify v1.1.4

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

Field of usage

Async highload calls to external API with rate limit.

Problem

For example you have async function func(...args), that use external API with rate limit 2 queries / second for one API key. Application produce calls independently and you are searching for way to run they in most efficient way. This is sequental run with guard period.

Soulution

const queueify = require("async-queueify");
Decorate func to funcQ = queueify(func, guardTime) where guardTime = 500 in milliseconds. Now you can await funcQ(...args) anywhere in your code and they will make queue. Only one instance of func will run in one time and only after guard time period. Make decorated instance funcQ once and then use it. Don't ququeify one function many times.

Parallel sequences

If you have async function funcMany([args1, args2, ...]), that can handle many requests by one API call, you can decorate it like funcManyQ = queueify(func, guardTime, maxOnce) where maxOnce is maximum requests for one funcMany call.

Errors in parallel sequences

Use checkError function in funcManyQ = queueify(func, guardTime, maxOnce, checkError) to return error to produce error in some results. checkError(result, args)

1.1.4

6 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago