This documentation is currently being moved to our new documentation site.

Please view or edit the documentation there, instead.

If you're looking for Fluid Project coordination, design, communication, etc, try the Fluid Project Wiki.

fluid.remove_if

fluid.remove_if(source, fn)

Scan through a list of objects, removing those which match a predicate. Similar to jQuery.grep, only acts on the list in-place by removal, rather than by creating a new list by inclusion.

fluid.remove_if(source, fn);

File name: Fluid.js

Parameters

source (Array or Object) The list of objects to be scanned over.
fn (Type) A predicate function determining whether an element should be removed. This accepts the standard signature (object, index) and returns a "truthy" result to indicate that the supplied object should be removed from the list.

Return Value

(Array or Object) The source, transformed by the operation of removing the matched elements. The supplied list is modified by this operation..


Example

fluid.remove_if(listOfPermissions, function (permItem) {
    return !permManager.resolve(permItem);
});

In this example, each object in a list of permission objects is examined using a function called permManager.resolve(). If this function fails to resolve the item, it will be removed from the list.