collectionSome

Similar to collectionEvery, except it returns true if at least one item returns true

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

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 collectionSome function

When only mail items are provided

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

Expected Result: false

When comment items are provided besides mail items as well

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

Expected Result: true

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

Fork me on GitHub