@zkochan/pnpm
Version:
A fast implementation of npm install
27 lines (24 loc) • 726 B
JavaScript
/*!
* lunr.trimmer
* Copyright (C) @YEAR Oliver Nightingale
*/
/**
* lunr.trimmer is a pipeline function for trimming non word
* characters from the begining and end of tokens before they
* enter the index.
*
* This implementation may not work correctly for non latin
* characters and should either be removed or adapted for use
* with languages with non-latin characters.
*
* @module
* @param {String} token The token to pass through the filter
* @returns {String}
* @see lunr.Pipeline
*/
lunr.trimmer = function (token) {
var result = token.replace(/^\W+/, '')
.replace(/\W+$/, '')
return result === '' ? undefined : result
}
lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')