UNPKG

deburr

Version:

Utility that simplifies substring search by normalizing character set. Diacritic marks and supplementary letters are converted to nearest ASCII character sequence before search.

31 lines (17 loc) 1.24 kB
# Deburr v0.0.3 [![Build Status](https://travis-ci.org/smikhalevski/deburr.svg)](https://travis-ci.org/smikhalevski/deburr) Utility that simplifies substring search by normalizing character set. Diacritic marks and supplementary letters are converted to nearest ASCII character sequence before search. ```javascript new Deburr('Flíeßendes wáßer').lookup('wasser'); // → {offset: 11, length: 5} ``` ## API #### <code>new Deburr (<i>*</i> value)</code> Creates new `Deburr` instance. Provided value is casted to string and for equal string representation same `Deburr` instance is returned. #### <code><i>String</i> toString ()</code> Returns normalized string representation of this `Deburr` instance. #### <code><i>{offset, length}</i> lookup(<i>String</i> substring, <i>Number</i> [beginIndex = 0])</code> Returns object that describes range of substring that matches `substring`. If no matches were found `null` is returned. #### <code><i>Array.&lt;{offset, length}&gt;</i> lookupAll(<i>String</i> substring, <i>Number</i> [beginIndex = 0], <i>Number</i> [count])</code> Returns array of ranges of matched substrings. ## License The code is available under [MIT licence](LICENSE.txt).