fast-fuzzy
Advanced tools
Comparing version 1.11.2 to 1.12.0
@@ -13,2 +13,3 @@ declare module 'fast-fuzzy' { | ||
useSellers?: boolean, | ||
useSeparatedUnicode?: boolean, | ||
returnMatchData?: boolean, | ||
@@ -15,0 +16,0 @@ sortBy?: sortKind, |
@@ -9,2 +9,4 @@ 'use strict'; | ||
const splitUnicode = str => str.normalize("NFKD").split(""); | ||
const whitespaceRegex = /^\s+$/; | ||
@@ -26,2 +28,3 @@ const nonWordRegex = /^[`~!@#$%^&*()\-=_+{}[\]\|\\;':",./<>?]+$/; | ||
useSellers: true, | ||
useSeparatedUnicode: false, | ||
sortBy: sortKind.bestMatch | ||
@@ -42,4 +45,5 @@ }; | ||
let length = 0; | ||
const graphemeList = options.useSeparatedUnicode ? splitUnicode(lower) : split(lower); | ||
for (const grapheme of split(lower)) { | ||
for (const grapheme of graphemeList) { | ||
whitespaceRegex.lastIndex = 0; | ||
@@ -55,3 +59,8 @@ nonWordRegex.lastIndex = 0; | ||
} else if (!(options.ignoreSymbols && nonWordRegex.test(grapheme))) { | ||
normal.push(grapheme.normalize()); | ||
if (options.useSeparatedUnicode) { | ||
normal.push(grapheme); | ||
} else { | ||
normal.push(grapheme.normalize()); | ||
} | ||
map.push(length); | ||
@@ -58,0 +67,0 @@ lastWasWhitespace = false; |
{ | ||
"name": "fast-fuzzy", | ||
"version": "1.11.2", | ||
"version": "1.12.0", | ||
"description": "Fast and tiny fuzzy-search utility", | ||
@@ -5,0 +5,0 @@ "main": "lib/fuzzy.js", |
@@ -67,2 +67,3 @@ # fast-fuzzy [![Build Status](https://travis-ci.com/EthanRutherford/fast-fuzzy.svg?branch=master)](https://travis-ci.com/EthanRutherford/fast-fuzzy) [![npm](https://img.shields.io/npm/v/fast-fuzzy.svg)](https://www.npmjs.com/package/fast-fuzzy) | ||
| useSellers | `Bool` | use the Sellers method for substring matching | `true` | ||
| useSeparatedUnicode | `Bool` | use separated unicode | `false` | ||
| sortBy | `sortKind` | defines which order results are returned in<sup>6</sup> | `bestMatch` | ||
@@ -69,0 +70,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43156
9
962
146