collectionMap

Maps values in a collection

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

This function requires Lucee.  Not supported on Adobe ColdFusion, etc.

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,

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub