collectionMap

Maps values in a collection

collectionMap(collection, closure [, parallel] [, maxThreads]) → returns any

This function requires Lucee. Not supported on Adobe ColdFusion.

collectionMap Argument Reference

collection any
Required

closure function
Required

parallel boolean

maxThreads numeric
Default: 20

Examples sample code invoking the collectionMap function

coll = [{
    id: 0,
    firstname: 'Arthur',
    name: 'Dent'
},{
    id: 1,
    firstname: 'Harry',
    name: 'Potter'
},{
    id: 2,
    firstname: 'Peter',
    name: 'Jackson'
}];
users = collectionMap(coll,function(item) {
    return {
        id: item.id,
        fullname: item.firstname&' '&item.name
    };
});
for(user in users) {
    writeOutput(user.fullname&', ');
}

Expected Result: Arthur Dent, Harry Potter, Peter Jackson,


Fork me on GitHub