Tuesday, 25 April 2017

Can Array of function which are dependent be solved by reduce method of bluebird?

Can anyone please clarify this reduce function of bluebird ... How it works ? How to use this ??

I want this function work like async.waterfall([ARRAY OF FUNCTIONS])

"use strict";
var Promise = require('bluebird');
var fs = Promise.promisifyAll(require('fs'));

Promise.reduce([function() {
        return 'Hardy';
    }, function(name) {
        console.log('0000' + name);
        return name + ' Jack';

    }, function(fullName) {
        console.log('000011' + fullName);
        return fullName + ' Danial';
    }],
    function(total, data) {
        console.log(total);
        console.log(data);
    }, 0).then(function(total) {
    //Total is 30
});



via hardy

No comments:

Post a Comment