0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2025-03-04 02:02:39 -05:00
verdaccio/node_modules/lunr/lib/trimmer.js
2014-11-25 03:08:06 +03:00

26 lines
665 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) {
return token
.replace(/^\W+/, '')
.replace(/\W+$/, '')
}
lunr.Pipeline.registerFunction(lunr.trimmer, 'trimmer')