@tanstack/match-sorter-utils
Advanced tools
Comparing version 8.1.1 to 8.5.14
@@ -43,6 +43,4 @@ /** | ||
function rankItem(item, value, options) { | ||
var _options$threshold; | ||
options = options || {}; | ||
options.threshold = (_options$threshold = options.threshold) != null ? _options$threshold : rankings.MATCHES; | ||
options.threshold = options.threshold ?? rankings.MATCHES; | ||
@@ -77,3 +75,3 @@ if (!options.accessors) { | ||
maxRanking, | ||
threshold | ||
threshold = options.threshold | ||
} = rankValue.attributes; | ||
@@ -89,4 +87,5 @@ | ||
if (newRank > rankingInfo.rank) { | ||
if (newRank >= threshold && newRank > rankingInfo.rank) { | ||
rankingInfo.rank = newRank; | ||
rankingInfo.passed = true; | ||
rankingInfo.accessorIndex = i; | ||
@@ -135,3 +134,3 @@ rankingInfo.accessorThreshold = threshold; | ||
if (testString.includes(" " + stringToRank)) { | ||
if (testString.includes(` ${stringToRank}`)) { | ||
return rankings.WORD_STARTS_WITH; | ||
@@ -259,3 +258,3 @@ } // contains | ||
// so part of preparing the value for comparison is ensure that it is a string | ||
value = "" + value; // toString | ||
value = `${value}`; // toString | ||
@@ -262,0 +261,0 @@ if (!keepDiacritics) { |
@@ -446,6 +446,4 @@ /** | ||
function rankItem(item, value, options) { | ||
var _options$threshold; | ||
options = options || {}; | ||
options.threshold = (_options$threshold = options.threshold) != null ? _options$threshold : rankings.MATCHES; | ||
options.threshold = options.threshold ?? rankings.MATCHES; | ||
@@ -480,3 +478,3 @@ if (!options.accessors) { | ||
maxRanking, | ||
threshold | ||
threshold = options.threshold | ||
} = rankValue.attributes; | ||
@@ -492,4 +490,5 @@ | ||
if (newRank > rankingInfo.rank) { | ||
if (newRank >= threshold && newRank > rankingInfo.rank) { | ||
rankingInfo.rank = newRank; | ||
rankingInfo.passed = true; | ||
rankingInfo.accessorIndex = i; | ||
@@ -538,3 +537,3 @@ rankingInfo.accessorThreshold = threshold; | ||
if (testString.includes(" " + stringToRank)) { | ||
if (testString.includes(` ${stringToRank}`)) { | ||
return rankings.WORD_STARTS_WITH; | ||
@@ -662,3 +661,3 @@ } // contains | ||
// so part of preparing the value for comparison is ensure that it is a string | ||
value = "" + value; // toString | ||
value = `${value}`; // toString | ||
@@ -665,0 +664,0 @@ if (!keepDiacritics) { |
@@ -13,7 +13,7 @@ { | ||
{ | ||
"uid": "e63b-225", | ||
"uid": "ebf9-229", | ||
"name": "remove-accents.ts" | ||
}, | ||
{ | ||
"uid": "e63b-227", | ||
"uid": "ebf9-231", | ||
"name": "index.ts" | ||
@@ -29,20 +29,20 @@ } | ||
"nodeParts": { | ||
"e63b-225": { | ||
"ebf9-229": { | ||
"renderedLength": 5602, | ||
"gzipLength": 1577, | ||
"brotliLength": 0, | ||
"mainUid": "e63b-224" | ||
"mainUid": "ebf9-228" | ||
}, | ||
"e63b-227": { | ||
"renderedLength": 9521, | ||
"gzipLength": 2802, | ||
"ebf9-231": { | ||
"renderedLength": 9520, | ||
"gzipLength": 2798, | ||
"brotliLength": 0, | ||
"mainUid": "e63b-226" | ||
"mainUid": "ebf9-230" | ||
} | ||
}, | ||
"nodeMetas": { | ||
"e63b-224": { | ||
"ebf9-228": { | ||
"id": "/packages/match-sorter-utils/src/remove-accents.ts", | ||
"moduleParts": { | ||
"index.production.js": "e63b-225" | ||
"index.production.js": "ebf9-229" | ||
}, | ||
@@ -52,14 +52,14 @@ "imported": [], | ||
{ | ||
"uid": "e63b-226" | ||
"uid": "ebf9-230" | ||
} | ||
] | ||
}, | ||
"e63b-226": { | ||
"ebf9-230": { | ||
"id": "/packages/match-sorter-utils/src/index.ts", | ||
"moduleParts": { | ||
"index.production.js": "e63b-227" | ||
"index.production.js": "ebf9-231" | ||
}, | ||
"imported": [ | ||
{ | ||
"uid": "e63b-224" | ||
"uid": "ebf9-228" | ||
} | ||
@@ -72,3 +72,3 @@ ], | ||
"env": { | ||
"rollup": "2.75.7" | ||
"rollup": "2.79.1" | ||
}, | ||
@@ -75,0 +75,0 @@ "options": { |
@@ -452,6 +452,4 @@ /** | ||
function rankItem(item, value, options) { | ||
var _options$threshold; | ||
options = options || {}; | ||
options.threshold = (_options$threshold = options.threshold) != null ? _options$threshold : rankings.MATCHES; | ||
options.threshold = options.threshold ?? rankings.MATCHES; | ||
@@ -486,3 +484,3 @@ if (!options.accessors) { | ||
maxRanking, | ||
threshold | ||
threshold = options.threshold | ||
} = rankValue.attributes; | ||
@@ -498,4 +496,5 @@ | ||
if (newRank > rankingInfo.rank) { | ||
if (newRank >= threshold && newRank > rankingInfo.rank) { | ||
rankingInfo.rank = newRank; | ||
rankingInfo.passed = true; | ||
rankingInfo.accessorIndex = i; | ||
@@ -544,3 +543,3 @@ rankingInfo.accessorThreshold = threshold; | ||
if (testString.includes(" " + stringToRank)) { | ||
if (testString.includes(` ${stringToRank}`)) { | ||
return rankings.WORD_STARTS_WITH; | ||
@@ -668,3 +667,3 @@ } // contains | ||
// so part of preparing the value for comparison is ensure that it is a string | ||
value = "" + value; // toString | ||
value = `${value}`; // toString | ||
@@ -671,0 +670,0 @@ if (!keepDiacritics) { |
@@ -18,3 +18,3 @@ /** | ||
*/ | ||
const o={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};function s(e,n,t){return e=a(e,t),(n=a(n,t)).length>e.length?o.NO_MATCH:e===n?o.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase())===(n=n.toLowerCase())?o.EQUAL:e.startsWith(n)?o.STARTS_WITH:e.includes(" "+n)?o.WORD_STARTS_WITH:e.includes(n)?o.CONTAINS:1===n.length?o.NO_MATCH:function(e){let n="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{n+=e.substr(0,1)}))})),n}(e).includes(n)?o.ACRONYM:function(e,n){let t=0,r=0;function s(e,n,r){for(let o=r,s=n.length;o<s;o++){if(n[o]===e)return t+=1,o+1}return-1}function a(e){const r=1/e,s=t/n.length;return o.MATCHES+s*r}const i=s(n[0],e,0);if(i<0)return o.NO_MATCH;r=i;for(let t=1,a=n.length;t<a;t++){r=s(n[t],e,r);if(!(r>-1))return o.NO_MATCH}return a(r-i)}(e,n)}function a(e,t){let{keepDiacritics:o}=t;return e=""+e,o||(e=e.replace(r,(e=>n[e]))),e}function i(e,n){let t=n;"object"==typeof n&&(t=n.accessor);const r=t(e);return null==r?[]:Array.isArray(r)?r:[String(r)]}const u={maxRanking:1/0,minRanking:-1/0};function c(e){return"function"==typeof e?u:{...u,...e}}e.compareItems=function(e,n){return e.rank===n.rank?0:e.rank>n.rank?-1:1},e.rankItem=function(e,n,t){var r;if((t=t||{}).threshold=null!=(r=t.threshold)?r:o.MATCHES,!t.accessors){const r=s(e,n,t);return{rankedValue:e,rank:r,accessorIndex:-1,accessorThreshold:t.threshold,passed:r>=t.threshold}}const a=function(e,n){const t=[];for(let r=0,o=n.length;r<o;r++){const o=n[r],s=c(o),a=i(e,o);for(let e=0,n=a.length;e<n;e++)t.push({itemValue:a[e],attributes:s})}return t}(e,t.accessors),u={rankedValue:e,rank:o.NO_MATCH,accessorIndex:-1,accessorThreshold:t.threshold,passed:!1};for(let e=0;e<a.length;e++){const r=a[e];let i=s(r.itemValue,n,t);const{minRanking:c,maxRanking:l,threshold:A}=r.attributes;i<c&&i>=o.MATCHES?i=c:i>l&&(i=l),i=Math.min(i,l),i>u.rank&&(u.rank=i,u.accessorIndex=e,u.accessorThreshold=A,u.rankedValue=r.itemValue)}return u},e.rankings=o,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
const o={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};function s(e,n,t){return e=a(e,t),(n=a(n,t)).length>e.length?o.NO_MATCH:e===n?o.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase())===(n=n.toLowerCase())?o.EQUAL:e.startsWith(n)?o.STARTS_WITH:e.includes(` ${n}`)?o.WORD_STARTS_WITH:e.includes(n)?o.CONTAINS:1===n.length?o.NO_MATCH:function(e){let n="";return e.split(" ").forEach((e=>{e.split("-").forEach((e=>{n+=e.substr(0,1)}))})),n}(e).includes(n)?o.ACRONYM:function(e,n){let t=0,r=0;function s(e,n,r){for(let o=r,s=n.length;o<s;o++){if(n[o]===e)return t+=1,o+1}return-1}function a(e){const r=1/e,s=t/n.length;return o.MATCHES+s*r}const i=s(n[0],e,0);if(i<0)return o.NO_MATCH;r=i;for(let t=1,a=n.length;t<a;t++){r=s(n[t],e,r);if(!(r>-1))return o.NO_MATCH}return a(r-i)}(e,n)}function a(e,t){let{keepDiacritics:o}=t;return e=`${e}`,o||(e=e.replace(r,(e=>n[e]))),e}function i(e,n){let t=n;"object"==typeof n&&(t=n.accessor);const r=t(e);return null==r?[]:Array.isArray(r)?r:[String(r)]}const u={maxRanking:1/0,minRanking:-1/0};function c(e){return"function"==typeof e?u:{...u,...e}}e.compareItems=function(e,n){return e.rank===n.rank?0:e.rank>n.rank?-1:1},e.rankItem=function(e,n,t){if((t=t||{}).threshold=t.threshold??o.MATCHES,!t.accessors){const r=s(e,n,t);return{rankedValue:e,rank:r,accessorIndex:-1,accessorThreshold:t.threshold,passed:r>=t.threshold}}const r=function(e,n){const t=[];for(let r=0,o=n.length;r<o;r++){const o=n[r],s=c(o),a=i(e,o);for(let e=0,n=a.length;e<n;e++)t.push({itemValue:a[e],attributes:s})}return t}(e,t.accessors),a={rankedValue:e,rank:o.NO_MATCH,accessorIndex:-1,accessorThreshold:t.threshold,passed:!1};for(let e=0;e<r.length;e++){const i=r[e];let u=s(i.itemValue,n,t);const{minRanking:c,maxRanking:l,threshold:A=t.threshold}=i.attributes;u<c&&u>=o.MATCHES?u=c:u>l&&(u=l),u=Math.min(u,l),u>=A&&u>a.rank&&(a.rank=u,a.passed=!0,a.accessorIndex=e,a.accessorThreshold=A,a.rankedValue=i.itemValue)}return a},e.rankings=o,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.production.js.map |
@@ -7,3 +7,3 @@ { | ||
], | ||
"version": "8.1.1", | ||
"version": "8.5.14", | ||
"description": "A fork of match-sorter with separated filtering and sorting phases", | ||
@@ -10,0 +10,0 @@ "license": "MIT", |
@@ -115,3 +115,3 @@ /** | ||
const { minRanking, maxRanking, threshold } = rankValue.attributes | ||
const { minRanking, maxRanking, threshold = options.threshold } = rankValue.attributes | ||
@@ -126,4 +126,5 @@ if (newRank < minRanking && newRank >= rankings.MATCHES) { | ||
if (newRank > rankingInfo.rank) { | ||
if (newRank >= threshold && newRank > rankingInfo.rank) { | ||
rankingInfo.rank = newRank | ||
rankingInfo.passed = true | ||
rankingInfo.accessorIndex = i | ||
@@ -130,0 +131,0 @@ rankingInfo.accessorThreshold = threshold |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
355443
2987