Class SpazFilterChain

Defined in: spazfilterchain.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

The SpazFilterChain is intended to create a chain of filters for processing some input.

Method Summary
Method Attributes Method Name and Description
 
addFilter(label, func, position)

add a filter to the chain

 

find the array index of a given filter

 

Returns an array of all the labels of filters in the chain

 

move the identified filter to the front of the chain

 

takes a filter label and moves that filter to last in the chain

 

removes all filters in the chain

 
process(input)

takes input and processes it through each filter in the chain, returning the final result

 
processArray(input_array)

like process, but takes an array and processes each item through the filter chain

 
removeFilter(label)

remove a filter from the chain

Class Detail

SpazFilterChain(opts)

The SpazFilterChain is intended to create a chain of filters for processing some input. There are no restrictions on the type of input, but all filter functions must expect the same type of input, and return the same type of output All filter functions must be synchronous -- they need to take input and return the modified version

Parameters:
opts
Method Detail

addFilter(label, func, position)

add a filter to the chain

Parameters:
{string} label
the label for this filter. REQUIRED
{function} func
the filter function. REQUIRED
position

{Number|Boolean} getFilterIndex(label)

find the array index of a given filter

Parameters:
{string} label
the label for a filter in the chain
Returns:
{Number|Boolean} the position of the filter, or FALSE if not found

{array} getFilterList()

Returns an array of all the labels of filters in the chain

Returns:
{array}

makeFilterFirst(label)

move the identified filter to the front of the chain

Parameters:
{string} label
the filter's label

makeFilterLast(label)

takes a filter label and moves that filter to last in the chain

Parameters:
{string} label
the label for a filter in the chain

nukeFilters()

removes all filters in the chain

{Mixed} process(input)

takes input and processes it through each filter in the chain, returning the final result

Parameters:
{Mixed} input
The input
Returns:
{Mixed} the output

{Array} processArray(input_array)

like process, but takes an array and processes each item through the filter chain

Parameters:
{Array} input_array
the input array
Returns:
{Array} the processed array

removeFilter(label)

remove a filter from the chain

Parameters:
label