1.6.2 • Published 8 years ago

pacu v1.6.2

Weekly downloads
6
License
ISC
Repository
github
Last release
8 years ago

pacu

It is a tool to solve the problem of resolving serise promise functions with parameter continuously. And there is not a solution but only resolving parallelly.

NPM

Install

$ npm install --save pacu

Usage

Initializing pacu

var pacu = require("pacu")

Important

To accomplish running promise function one after one is difficult, because the object format of promise function and promise function with parameter are different in js ( issue of anonymous function with parameters ). So that handling this issue needed to push promise function(not a promise) to an array list, which will be resolved:

    var genPromist = function(para) {
        return new Promise(function(resolve, reject) {
            setTimeout(function() {
                console.log('para: ', para)
                resolve(para * para)
            }, 1000)
        })
    };

    var promisesList = [];

    promisesList.push(function(){
        return genPromist(i)
    });
## Usage
//processing promiseList by series

var pacu = require("pacu")

pacu.series(promisesList).then(function(result) {
    console.log("Result series: ", result)
},function(err){
    console.log("Error series: ", result)
});
## Usage closure design
//processing promiseList by series in closure design

var PACU = require("pacu")
var pacu = new PACU(promisesList)

pacu.series(promisesList).then(function(result) {
    console.log("Result series: ", result)
},function(err){
    console.log("Error series: ", result)
});

License

MIT

1.6.2

8 years ago

1.6.1

8 years ago

1.6.0

8 years ago

1.5.0

8 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago