Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Div
classapi-page

fluid.filterKeys(toFilter, keys, exclude)

Section
Column
width70%

Accepts an object to be filtered, and a list of keys. Either all keys not present in the list are removed, or only keys present in the list are removed.

Code Block
javascript
javascript
bgColorwhite
borderStylenonejavascript
fluid.filterKeys(toFilter, keys, exclude);

File name: Fluid.js

Parameters

Span
classborderless-table

toFilter

(Arrayable or Object) The object to be filtered - this will be modified by the operation.

keys

(Array of strings) The list of keys to operate with.

exclude

(boolean) If true, the keys listed are removed rather than included. Default is false, i.e. by default, everything is removed but the listed keys.

Return Value

Span
classborderless-table

Object

the filtered object (the same object that was supplied as toFilter).

Column
width5%

Column

See Also


Example

Code Block
javascript
javascript
fluid.each(addressArray, function (addr, index) {
    fluid.filterKeys(addr, ["city, "country"]);
});

This example processes an array of address objects and strips all but the City and Country information from them. Note that this example is destructive: It directly modifies the original objects in addressArray.

Example: non-destructive

Code Block
javascript
javascript
var demographics = [];
fluid.each(addressArray, function (addr, index) {
    demographics.push(fluid.filterKeys(fluid.copy(addr), ["city, "country"]));
});

This example produces a new array of objects containing only the City and Country information in addressArray.

Example

Code Block
javascript
javascript
fluid.each(addressArray, function (addr, index) {
    fluid.filterKeys(addr, ["name"], true);
});

This example processes an array of address objects and makes it "anonymous" it by stripping out the name fields. Note that this example is destructive: It directly modifies the original objects in addressArray.