Loading TOC...

WordsSearch.reduce

WordsSearch.reduce(
   $reducer as function,
   $seed as anyValue
) as WordsSearch

Summary

Specifies a function similar to Array.prototype.reduce() to apply to each word within the slice.

Parameters
$reducer The reducing function.
$seed The initial reduction passed to the reducing function.

Usage Notes

Your custom reducer function should have the following signature:

function (prev, current, index, state)

Where the parameters have the following contents:

prev
The value returned by the previous call, or the seed value on the first call.
current
The current word.
index
The number of the current word.
state
A state object with a boolean-valued isLast> property that indicated the last call. You can set it to true to prematurely halt the reduction.

The return from the last call becomes the final reduced result.

You cannot use this method in conjunction with WordsSearch.map.

See Also

Comments

    Powered by MarkLogic Server 7.0-4.1 and rundmc | Terms of Use | Privacy Policy