collectionEvery

Checks if every item passes the truth test of an expression given in the closure

collectionEvery(collection, closure [, parallel] [, maxThreads]) → returns boolean

This function requires Lucee. Not supported on Adobe ColdFusion.

collectionEvery Argument Reference

collection any
Required

closure function
Required

parallel boolean

maxThreads numeric
Default: 20

Examples sample code invoking the collectionEvery function

When only mail items are provided

coll = [{
    id: 0,
    type: 'mail'
},{
    id: 1,
    type: 'mail'
}];
onlyMails = collectionEvery(coll,function(item) {
    return item.type is 'mail';
});
writeOutput(onlyMails);

Expected Result: true

When comment items are provided besides mail items as well

coll = [{
    id: 0,
    type: 'mail'
},{
    id: 1,
    type: 'mail'
},{
    id: 2,
    type: 'comment'
}];
onlyMails = collectionEvery(coll,function(item) {
    return item.type is 'mail';
});
writeOutput(onlyMails);

Expected Result: false


Fork me on GitHub