Map/Reduce


Get R2Javascript for webMethods Integration Server

Example

exports.flow = function(input) {
    var total = input.docs 
    .map(function(doc) {
        doc.amount = (+doc.price) * (+doc.quantity);
    })
    .reduce(function(sum, doc) {
        return sum + doc.amount;
    }), 0);
    
    return {total: total};
};

In the above example '+doc.price' is a Javascript idiom to convert a string to a number.

R2 ehf.

Lækjargata 12
101 Reykjavík
ICELAND