Loading TOC...


   $mapper as objectOrFuncRef
) as WordsSearch


Specifies a function similar to Array.prototype.map() to apply to each word within the slice. Exclusive with respect to the reduce() clause.

$mapper The mapping function or configuration for the built-in mapper.

Usage Notes

Your custom mapper function is invoked on each word in the current slice. Your custom mapper should have the following signature:

function (currentItem)

Where the single input is the current word to act on. If the function returns a value, the value is pushed on to the results array.

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

See Also


// Returns true if the input is on my black list
function isInBlackList(word) {...};

const jsearch = require('/MarkLogic/jsearch.sjs');
  .map(function (word) {
    return isInBlackList(word) ? undefined : word

// Result: An array of words in 'title' word lexicon that are not blacklisted


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