Skip to content

Commit

Permalink
set all unspecified intra char tolerances to 1 when intraMode: 1, else 0
Browse files Browse the repository at this point in the history
  • Loading branch information
leeoniya committed Dec 22, 2023
1 parent 8da3f48 commit ab876aa
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 18 deletions.
13 changes: 9 additions & 4 deletions dist/uFuzzy.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const OPTS = {

// allowance between chars in terms
intraChars: "[a-z\\d']", // internally case-insensitive
intraIns: 0,
intraIns: null,

intraContr: "'[a-z]{1,2}\\b",

Expand All @@ -61,9 +61,9 @@ const OPTS = {
intraSlice: [1, inf],

// single-error tolerance toggles
intraSub: 0,
intraTrn: 0,
intraDel: 0,
intraSub: null,
intraTrn: null,
intraDel: null,

// can post-filter matches that are too far apart in distance or length
// (since intraIns is between each char, it can accum to nonsense matches)
Expand Down Expand Up @@ -135,6 +135,11 @@ function uFuzzy(opts) {
intraChars,
} = opts;

intraIns ??= intraMode;
intraSub ??= intraMode;
intraTrn ??= intraMode;
intraDel ??= intraMode;

let alpha = opts.letters ?? opts.alpha;

if (alpha != null) {
Expand Down
13 changes: 9 additions & 4 deletions dist/uFuzzy.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const OPTS = {

// allowance between chars in terms
intraChars: "[a-z\\d']", // internally case-insensitive
intraIns: 0,
intraIns: null,

intraContr: "'[a-z]{1,2}\\b",

Expand All @@ -59,9 +59,9 @@ const OPTS = {
intraSlice: [1, inf],

// single-error tolerance toggles
intraSub: 0,
intraTrn: 0,
intraDel: 0,
intraSub: null,
intraTrn: null,
intraDel: null,

// can post-filter matches that are too far apart in distance or length
// (since intraIns is between each char, it can accum to nonsense matches)
Expand Down Expand Up @@ -133,6 +133,11 @@ function uFuzzy(opts) {
intraChars,
} = opts;

intraIns ??= intraMode;
intraSub ??= intraMode;
intraTrn ??= intraMode;
intraDel ??= intraMode;

let alpha = opts.letters ?? opts.alpha;

if (alpha != null) {
Expand Down
13 changes: 9 additions & 4 deletions dist/uFuzzy.iife.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ var uFuzzy = (function () {

// allowance between chars in terms
intraChars: "[a-z\\d']", // internally case-insensitive
intraIns: 0,
intraIns: null,

intraContr: "'[a-z]{1,2}\\b",

Expand All @@ -62,9 +62,9 @@ var uFuzzy = (function () {
intraSlice: [1, inf],

// single-error tolerance toggles
intraSub: 0,
intraTrn: 0,
intraDel: 0,
intraSub: null,
intraTrn: null,
intraDel: null,

// can post-filter matches that are too far apart in distance or length
// (since intraIns is between each char, it can accum to nonsense matches)
Expand Down Expand Up @@ -136,6 +136,11 @@ var uFuzzy = (function () {
intraChars,
} = opts;

intraIns ??= intraMode;
intraSub ??= intraMode;
intraTrn ??= intraMode;
intraDel ??= intraMode;

let alpha = opts.letters ?? opts.alpha;

if (alpha != null) {
Expand Down
2 changes: 1 addition & 1 deletion dist/uFuzzy.iife.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@
"homepage": "https://github.com/leeoniya/uFuzzy#readme",
"devDependencies": {
"@rollup/plugin-terser": "^0.4.4",
"rollup": "^4.7.0"
"rollup": "^4.9.1"
}
}
13 changes: 9 additions & 4 deletions src/uFuzzy.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const OPTS = {

// allowance between chars in terms
intraChars: "[a-z\\d']", // internally case-insensitive
intraIns: 0,
intraIns: null,

intraContr: "'[a-z]{1,2}\\b",

Expand All @@ -52,9 +52,9 @@ const OPTS = {
intraSlice: [1, inf],

// single-error tolerance toggles
intraSub: 0,
intraTrn: 0,
intraDel: 0,
intraSub: null,
intraTrn: null,
intraDel: null,

// can post-filter matches that are too far apart in distance or length
// (since intraIns is between each char, it can accum to nonsense matches)
Expand Down Expand Up @@ -126,6 +126,11 @@ export default function uFuzzy(opts) {
intraChars,
} = opts;

intraIns ??= intraMode;
intraSub ??= intraMode;
intraTrn ??= intraMode;
intraDel ??= intraMode;

let alpha = opts.letters ?? opts.alpha;

if (alpha != null) {
Expand Down

0 comments on commit ab876aa

Please sign in to comment.