3.1.0 • Published 8 years ago

throttle-exec v3.1.0

Weekly downloads
79
License
ISC
Repository
-
Last release
8 years ago

throttle-exec

A simple job-queue manager based on Promise mechanims

Installation

$ npm install throttle-exec

Usage

var ThrottleEngine = require("throttle-exec")
var maximumProcess = 10
var throttleInstance = new ThrottleEngine(maximumProcess) 

Function that perform asynchronous logic

var wrappedAsync = throttleInstance.wrap(function(p1,p2){
    return new Promise(function(resolve,reject){
        var ret = {}
        // some logic
        resolve(ret)
    })
})
wrappedAsync("http://npmjs.org","http://google.com").then(function(ret){
    console.log(ret)
}).catch(console.error)

Function that perform synchronous logic

var wrappedSync = throttleInstance.wrap(function(p1,p2){
    
    // some logic
    return p1 * p2;
})
wrappedSync(5,2).then(function(result){
    console.log(result) // 10
}).catch(console.error) // any error will be thrown from try and trigger reject

GitHub

https://github.com/aerios/throttle-exec

3.1.0

8 years ago

3.0.4

9 years ago

3.0.3

9 years ago

3.0.2

9 years ago

3.0.1

9 years ago

3.0.0

9 years ago

2.3.0

9 years ago

2.2.3

9 years ago

2.2.2

10 years ago

2.2.1

10 years ago

2.2.0

10 years ago

2.1.0

10 years ago

2.0.0

10 years ago

1.1.0

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago