Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

match-sorter

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

match-sorter - npm Package Compare versions

Comparing version 1.7.0 to 1.8.0

48

dist/cjs/index.js

@@ -159,3 +159,5 @@ 'use strict';

return stringsByCharOrder(testString, stringToRank);
// will return a number between rankings.MATCHES and
// rankings.MATCHES + 1 depending on how close of a match it is.
return getClosenessRanking(testString, stringToRank);
}

@@ -182,28 +184,36 @@

/**
* Returns a rankings.matches or noMatch score based on whether
* the characters in the stringToRank are found in order in the
* testString
* Returns a score based on how spread apart the
* characters from the stringToRank are within the testString.
* A number close to rankings.MATCHES represents a loose match. A number close
* to rankings.MATCHES + 1 represents a loose match.
* @param {String} testString - the string to test against
* @param {String} stringToRank - the string to rank
* @returns {Number} the ranking for how well stringToRank matches testString
* @returns {Number} the number between rankings.MATCHES and
* rankings.MATCHES + 1 for how well stringToRank matches testString
*/
function stringsByCharOrder(testString, stringToRank) {
function getClosenessRanking(testString, stringToRank) {
var charNumber = 0;
function findMatchingCharacter(matchChar, string) {
var found = false;
for (var j = charNumber; j < string.length; j++) {
function findMatchingCharacter(matchChar, string, index) {
for (var j = index; j < string.length; j++) {
var stringChar = string[j];
if (stringChar === matchChar) {
found = true;
charNumber = j + 1;
break;
return j + 1;
}
}
return found;
return -1;
}
for (var i = 0; i < stringToRank.length; i++) {
function getRanking(spread) {
var matching = spread - stringToRank.length + 1;
var ranking = rankings.MATCHES + 1 / matching;
return ranking;
}
var firstIndex = findMatchingCharacter(stringToRank[0], testString, 0);
if (firstIndex < 0) {
return rankings.NO_MATCH;
}
charNumber = firstIndex;
for (var i = 1; i < stringToRank.length; i++) {
var matchChar = stringToRank[i];
var found = findMatchingCharacter(matchChar, testString);
charNumber = findMatchingCharacter(matchChar, testString, charNumber);
var found = charNumber > -1;
if (!found) {

@@ -213,3 +223,5 @@ return rankings.NO_MATCH;

}
return rankings.MATCHES;
var spread = charNumber - firstIndex;
return getRanking(spread);
}

@@ -216,0 +228,0 @@

@@ -316,3 +316,5 @@ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

return stringsByCharOrder(testString, stringToRank);
// will return a number between rankings.MATCHES and
// rankings.MATCHES + 1 depending on how close of a match it is.
return getClosenessRanking(testString, stringToRank);
}

@@ -339,28 +341,36 @@

/**
* Returns a rankings.matches or noMatch score based on whether
* the characters in the stringToRank are found in order in the
* testString
* Returns a score based on how spread apart the
* characters from the stringToRank are within the testString.
* A number close to rankings.MATCHES represents a loose match. A number close
* to rankings.MATCHES + 1 represents a loose match.
* @param {String} testString - the string to test against
* @param {String} stringToRank - the string to rank
* @returns {Number} the ranking for how well stringToRank matches testString
* @returns {Number} the number between rankings.MATCHES and
* rankings.MATCHES + 1 for how well stringToRank matches testString
*/
function stringsByCharOrder(testString, stringToRank) {
function getClosenessRanking(testString, stringToRank) {
var charNumber = 0;
function findMatchingCharacter(matchChar, string) {
var found = false;
for (var j = charNumber; j < string.length; j++) {
function findMatchingCharacter(matchChar, string, index) {
for (var j = index; j < string.length; j++) {
var stringChar = string[j];
if (stringChar === matchChar) {
found = true;
charNumber = j + 1;
break;
return j + 1;
}
}
return found;
return -1;
}
for (var i = 0; i < stringToRank.length; i++) {
function getRanking(spread) {
var matching = spread - stringToRank.length + 1;
var ranking = rankings.MATCHES + 1 / matching;
return ranking;
}
var firstIndex = findMatchingCharacter(stringToRank[0], testString, 0);
if (firstIndex < 0) {
return rankings.NO_MATCH;
}
charNumber = firstIndex;
for (var i = 1; i < stringToRank.length; i++) {
var matchChar = stringToRank[i];
var found = findMatchingCharacter(matchChar, testString);
charNumber = findMatchingCharacter(matchChar, testString, charNumber);
var found = charNumber > -1;
if (!found) {

@@ -370,3 +380,5 @@ return rankings.NO_MATCH;

}
return rankings.MATCHES;
var spread = charNumber - firstIndex;
return getRanking(spread);
}

@@ -373,0 +385,0 @@

@@ -1,2 +0,2 @@

function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function matchSorter(e,t){function r(e,r,n){var o=getHighestRanking(r,a,t,s),i=o.rank,b=o.keyIndex;return i>=l&&e.push({item:r,rank:i,index:n,keyIndex:b}),e}var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=s.keys,n=s.threshold,l=void 0===n?rankings.MATCHES:n,o=e.reduce(r,[]);return o.sort(sortRankedItems).map(function(e){var t=e.item;return t})}function getHighestRanking(e,t,r,s){if(!t)return{rank:getMatchRanking(e,r,s),keyIndex:-1};var a=getAllValuesToRank(e,t);return a.reduce(function(e,t,a){var n=e.rank,l=e.keyIndex,o=t.itemValue,i=t.attributes,b=getMatchRanking(o,r,s);b>n&&(n=b,l=a);var u=i.minRanking,f=i.maxRanking;return n<u&&b>=rankings.MATCHES?n=u:n>f&&(n=f),{rank:n,keyIndex:l}},{rank:rankings.NO_MATCH,keyIndex:-1})}function getMatchRanking(e,t,r){return e=prepareValueForComparison(e,r),t=prepareValueForComparison(t,r),t.length>e.length?rankings.NO_MATCH:e===t?rankings.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase(),t=t.toLowerCase(),e===t?rankings.EQUAL:0===e.indexOf(t)?rankings.STARTS_WITH:e.indexOf(" "+t)!==-1?rankings.WORD_STARTS_WITH:e.indexOf(t)!==-1?rankings.CONTAINS:1===t.length?rankings.NO_MATCH:getAcronym(e).indexOf(t)!==-1?rankings.ACRONYM:stringsByCharOrder(e,t))}function getAcronym(e){var t="",r=e.split(" ");return r.forEach(function(e){var r=e.split("-");r.forEach(function(e){t+=e.substr(0,1)})}),t}function stringsByCharOrder(e,t){function r(e,t){for(var r=!1,a=s;a<t.length;a++){var n=t[a];if(n===e){r=!0,s=a+1;break}}return r}for(var s=0,a=0;a<t.length;a++){var n=t[a],l=r(n,e);if(!l)return rankings.NO_MATCH}return rankings.MATCHES}function sortRankedItems(e,t){var r=-1,s=1,a=e.rank,n=e.index,l=e.keyIndex,o=t.rank,i=t.index,b=t.keyIndex,u=a===o;return u?l===b?n<i?r:s:l<b?r:s:a>o?r:s}function prepareValueForComparison(e,t){var r=t.keepDiacritics;return e=""+e,r||(e=diacritics.clean(e)),e}function getItemValues(e,t){"object"===("undefined"==typeof t?"undefined":_typeof(t))&&(t=t.key);var r=void 0;return r="function"==typeof t?t(e):t.indexOf(".")!==-1?t.split(".").reduce(function(e,t){return e[t]},e):e[t],r?[].concat(r):null}function getAllValuesToRank(e,t){return t.reduce(function(t,r){var s=getItemValues(e,r);return s&&s.forEach(function(e){t.push({itemValue:e,attributes:getKeyAttributes(r)})}),t},[])}function getKeyAttributes(e){return"string"==typeof e&&(e={key:e}),_extends({maxRanking:1/0,minRanking:-(1/0)},e)}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},diacritics=createCommonjsModule(function(e){!function(t,r){e.exports?e.exports=r():this[t]=r()}("Diacritics",function(){for(var e={map:{}},t=[{base:" ",letters:" "},{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"Th",letters:"Þ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"ff",letters:"ff"},{base:"fi",letters:"fi"},{base:"fl",letters:"fl"},{base:"ffi",letters:"ffi"},{base:"ffl",letters:"ffl"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nñnⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ"},{base:"nj",letters:"nj"},{base:"o",letters:"߀oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oe",letters:"Œœ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"ss",letters:"ß"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"th",letters:"þ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],r=0,s=t.length;r<s;r++)for(var a=t[r].letters.split(""),n=0,l=a.length;n<l;n++)e.map[a[n]]=t[r].base;return e.clean=function(t){if(!t||!t.length||t.length<1)return"";for(var r,s="",a=t.split(""),n=0,l=a.length;n<l;n++)r=a[n],s+=r in e.map?e.map[r]:r;return s},e})}),globalObject=createCommonjsModule(function(module){!function(e){try{e("export default global")}catch(t){try{e("export default self")}catch(e){try{module.exports=commonjsGlobal}catch(e){try{self.global=self}catch(e){window.global=window}}}}}(eval)}),_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rankings={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};matchSorter.rankings=rankings,"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?(matchSorter.default=matchSorter,module.exports=matchSorter,Object.defineProperty(exports,"__esModule",{value:!0})):"function"==typeof define&&define.amd?define(function(){return matchSorter}):globalObject.matchSorter=matchSorter;
function createCommonjsModule(e,t){return t={exports:{}},e(t,t.exports),t.exports}function matchSorter(e,t){function r(e,r,a){var o=getHighestRanking(r,n,t,s),i=o.rank,b=o.keyIndex;return i>=l&&e.push({item:r,rank:i,index:a,keyIndex:b}),e}var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=s.keys,a=s.threshold,l=void 0===a?rankings.MATCHES:a,o=e.reduce(r,[]);return o.sort(sortRankedItems).map(function(e){var t=e.item;return t})}function getHighestRanking(e,t,r,s){if(!t)return{rank:getMatchRanking(e,r,s),keyIndex:-1};var n=getAllValuesToRank(e,t);return n.reduce(function(e,t,n){var a=e.rank,l=e.keyIndex,o=t.itemValue,i=t.attributes,b=getMatchRanking(o,r,s);b>a&&(a=b,l=n);var u=i.minRanking,f=i.maxRanking;return a<u&&b>=rankings.MATCHES?a=u:a>f&&(a=f),{rank:a,keyIndex:l}},{rank:rankings.NO_MATCH,keyIndex:-1})}function getMatchRanking(e,t,r){return e=prepareValueForComparison(e,r),t=prepareValueForComparison(t,r),t.length>e.length?rankings.NO_MATCH:e===t?rankings.CASE_SENSITIVE_EQUAL:(e=e.toLowerCase(),t=t.toLowerCase(),e===t?rankings.EQUAL:0===e.indexOf(t)?rankings.STARTS_WITH:e.indexOf(" "+t)!==-1?rankings.WORD_STARTS_WITH:e.indexOf(t)!==-1?rankings.CONTAINS:1===t.length?rankings.NO_MATCH:getAcronym(e).indexOf(t)!==-1?rankings.ACRONYM:getClosenessRanking(e,t))}function getAcronym(e){var t="",r=e.split(" ");return r.forEach(function(e){var r=e.split("-");r.forEach(function(e){t+=e.substr(0,1)})}),t}function getClosenessRanking(e,t){function r(e,t,r){for(var s=r;s<t.length;s++){var n=t[s];if(n===e)return s+1}return-1}function s(e){var r=e-t.length+1,s=rankings.MATCHES+1/r;return s}var n=0,a=r(t[0],e,0);if(a<0)return rankings.NO_MATCH;n=a;for(var l=1;l<t.length;l++){var o=t[l];n=r(o,e,n);var i=n>-1;if(!i)return rankings.NO_MATCH}var b=n-a;return s(b)}function sortRankedItems(e,t){var r=-1,s=1,n=e.rank,a=e.index,l=e.keyIndex,o=t.rank,i=t.index,b=t.keyIndex,u=n===o;return u?l===b?a<i?r:s:l<b?r:s:n>o?r:s}function prepareValueForComparison(e,t){var r=t.keepDiacritics;return e=""+e,r||(e=diacritics.clean(e)),e}function getItemValues(e,t){"object"===("undefined"==typeof t?"undefined":_typeof(t))&&(t=t.key);var r=void 0;return r="function"==typeof t?t(e):t.indexOf(".")!==-1?t.split(".").reduce(function(e,t){return e[t]},e):e[t],r?[].concat(r):null}function getAllValuesToRank(e,t){return t.reduce(function(t,r){var s=getItemValues(e,r);return s&&s.forEach(function(e){t.push({itemValue:e,attributes:getKeyAttributes(r)})}),t},[])}function getKeyAttributes(e){return"string"==typeof e&&(e={key:e}),_extends({maxRanking:1/0,minRanking:-(1/0)},e)}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},diacritics=createCommonjsModule(function(e){!function(t,r){e.exports?e.exports=r():this[t]=r()}("Diacritics",function(){for(var e={map:{}},t=[{base:" ",letters:" "},{base:"A",letters:"AⒶAÀÁÂẦẤẪẨÃĀĂẰẮẴẲȦǠÄǞẢÅǺǍȀȂẠẬẶḀĄȺⱯ"},{base:"AA",letters:"Ꜳ"},{base:"AE",letters:"ÆǼǢ"},{base:"AO",letters:"Ꜵ"},{base:"AU",letters:"Ꜷ"},{base:"AV",letters:"ꜸꜺ"},{base:"AY",letters:"Ꜽ"},{base:"B",letters:"BⒷBḂḄḆɃƂƁ"},{base:"C",letters:"CⒸCĆĈĊČÇḈƇȻꜾ"},{base:"D",letters:"DⒹDḊĎḌḐḒḎĐƋƊƉꝹ"},{base:"DZ",letters:"DZDŽ"},{base:"Dz",letters:"DzDž"},{base:"E",letters:"EⒺEÈÉÊỀẾỄỂẼĒḔḖĔĖËẺĚȄȆẸỆȨḜĘḘḚƐƎ"},{base:"F",letters:"FⒻFḞƑꝻ"},{base:"G",letters:"GⒼGǴĜḠĞĠǦĢǤƓꞠꝽꝾ"},{base:"H",letters:"HⒽHĤḢḦȞḤḨḪĦⱧⱵꞍ"},{base:"I",letters:"IⒾIÌÍÎĨĪĬİÏḮỈǏȈȊỊĮḬƗ"},{base:"J",letters:"JⒿJĴɈ"},{base:"K",letters:"KⓀKḰǨḲĶḴƘⱩꝀꝂꝄꞢ"},{base:"L",letters:"LⓁLĿĹĽḶḸĻḼḺŁȽⱢⱠꝈꝆꞀ"},{base:"LJ",letters:"LJ"},{base:"Lj",letters:"Lj"},{base:"M",letters:"MⓂMḾṀṂⱮƜ"},{base:"N",letters:"NⓃNǸŃÑṄŇṆŅṊṈȠƝꞐꞤ"},{base:"NJ",letters:"NJ"},{base:"Nj",letters:"Nj"},{base:"O",letters:"OⓄOÒÓÔỒỐỖỔÕṌȬṎŌṐṒŎȮȰÖȪỎŐǑȌȎƠỜỚỠỞỢỌỘǪǬØǾƆƟꝊꝌ"},{base:"OI",letters:"Ƣ"},{base:"OO",letters:"Ꝏ"},{base:"OU",letters:"Ȣ"},{base:"P",letters:"PⓅPṔṖƤⱣꝐꝒꝔ"},{base:"Q",letters:"QⓆQꝖꝘɊ"},{base:"R",letters:"RⓇRŔṘŘȐȒṚṜŖṞɌⱤꝚꞦꞂ"},{base:"S",letters:"SⓈSẞŚṤŜṠŠṦṢṨȘŞⱾꞨꞄ"},{base:"T",letters:"TⓉTṪŤṬȚŢṰṮŦƬƮȾꞆ"},{base:"Th",letters:"Þ"},{base:"TZ",letters:"Ꜩ"},{base:"U",letters:"UⓊUÙÚÛŨṸŪṺŬÜǛǗǕǙỦŮŰǓȔȖƯỪỨỮỬỰỤṲŲṶṴɄ"},{base:"V",letters:"VⓋVṼṾƲꝞɅ"},{base:"VY",letters:"Ꝡ"},{base:"W",letters:"WⓌWẀẂŴẆẄẈⱲ"},{base:"X",letters:"XⓍXẊẌ"},{base:"Y",letters:"YⓎYỲÝŶỸȲẎŸỶỴƳɎỾ"},{base:"Z",letters:"ZⓏZŹẐŻŽẒẔƵȤⱿⱫꝢ"},{base:"a",letters:"aⓐaẚàáâầấẫẩãāăằắẵẳȧǡäǟảåǻǎȁȃạậặḁąⱥɐɑ"},{base:"aa",letters:"ꜳ"},{base:"ae",letters:"æǽǣ"},{base:"ao",letters:"ꜵ"},{base:"au",letters:"ꜷ"},{base:"av",letters:"ꜹꜻ"},{base:"ay",letters:"ꜽ"},{base:"b",letters:"bⓑbḃḅḇƀƃɓ"},{base:"c",letters:"cⓒcćĉċčçḉƈȼꜿↄ"},{base:"d",letters:"dⓓdḋďḍḑḓḏđƌɖɗꝺ"},{base:"dz",letters:"dzdž"},{base:"e",letters:"eⓔeèéêềếễểẽēḕḗĕėëẻěȅȇẹệȩḝęḙḛɇɛǝ"},{base:"f",letters:"fⓕfḟƒꝼ"},{base:"ff",letters:"ff"},{base:"fi",letters:"fi"},{base:"fl",letters:"fl"},{base:"ffi",letters:"ffi"},{base:"ffl",letters:"ffl"},{base:"g",letters:"gⓖgǵĝḡğġǧģǥɠꞡᵹꝿ"},{base:"h",letters:"hⓗhĥḣḧȟḥḩḫẖħⱨⱶɥ"},{base:"hv",letters:"ƕ"},{base:"i",letters:"iⓘiìíîĩīĭïḯỉǐȉȋịįḭɨı"},{base:"j",letters:"jⓙjĵǰɉ"},{base:"k",letters:"kⓚkḱǩḳķḵƙⱪꝁꝃꝅꞣ"},{base:"l",letters:"lⓛlŀĺľḷḹļḽḻſłƚɫⱡꝉꞁꝇ"},{base:"lj",letters:"lj"},{base:"m",letters:"mⓜmḿṁṃɱɯ"},{base:"n",letters:"nñnⓝnǹńñṅňṇņṋṉƞɲʼnꞑꞥлԉ"},{base:"nj",letters:"nj"},{base:"o",letters:"߀oⓞoòóôồốỗổõṍȭṏōṑṓŏȯȱöȫỏőǒȍȏơờớỡởợọộǫǭøǿɔꝋꝍɵ"},{base:"oe",letters:"Œœ"},{base:"oi",letters:"ƣ"},{base:"ou",letters:"ȣ"},{base:"oo",letters:"ꝏ"},{base:"p",letters:"pⓟpṕṗƥᵽꝑꝓꝕ"},{base:"q",letters:"qⓠqɋꝗꝙ"},{base:"r",letters:"rⓡrŕṙřȑȓṛṝŗṟɍɽꝛꞧꞃ"},{base:"s",letters:"sⓢsßśṥŝṡšṧṣṩșşȿꞩꞅẛ"},{base:"ss",letters:"ß"},{base:"t",letters:"tⓣtṫẗťṭțţṱṯŧƭʈⱦꞇ"},{base:"th",letters:"þ"},{base:"tz",letters:"ꜩ"},{base:"u",letters:"uⓤuùúûũṹūṻŭüǜǘǖǚủůűǔȕȗưừứữửựụṳųṷṵʉ"},{base:"v",letters:"vⓥvṽṿʋꝟʌ"},{base:"vy",letters:"ꝡ"},{base:"w",letters:"wⓦwẁẃŵẇẅẘẉⱳ"},{base:"x",letters:"xⓧxẋẍ"},{base:"y",letters:"yⓨyỳýŷỹȳẏÿỷẙỵƴɏỿ"},{base:"z",letters:"zⓩzźẑżžẓẕƶȥɀⱬꝣ"}],r=0,s=t.length;r<s;r++)for(var n=t[r].letters.split(""),a=0,l=n.length;a<l;a++)e.map[n[a]]=t[r].base;return e.clean=function(t){if(!t||!t.length||t.length<1)return"";for(var r,s="",n=t.split(""),a=0,l=n.length;a<l;a++)r=n[a],s+=r in e.map?e.map[r]:r;return s},e})}),globalObject=createCommonjsModule(function(module){!function(e){try{e("export default global")}catch(t){try{e("export default self")}catch(e){try{module.exports=commonjsGlobal}catch(e){try{self.global=self}catch(e){window.global=window}}}}}(eval)}),_extends=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},rankings={CASE_SENSITIVE_EQUAL:7,EQUAL:6,STARTS_WITH:5,WORD_STARTS_WITH:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0};matchSorter.rankings=rankings,"object"===("undefined"==typeof exports?"undefined":_typeof(exports))&&"undefined"!=typeof module?(matchSorter.default=matchSorter,module.exports=matchSorter,Object.defineProperty(exports,"__esModule",{value:!0})):"function"==typeof define&&define.amd?define(function(){return matchSorter}):globalObject.matchSorter=matchSorter;
//# sourceMappingURL=match-sorter.min.js.map
{
"name": "match-sorter",
"version": "1.7.0",
"version": "1.8.0",
"description": "Simple, expected, and deterministic best-match sorting of an array in JavaScript",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

@@ -12,3 +12,3 @@ # match-sorter

[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors)
[![All Contributors](https://img.shields.io/badge/all_contributors-6-orange.svg?style=flat-square)](#contributors)
[![PRs Welcome][prs-badge]][prs]

@@ -42,3 +42,3 @@ [![Donate][donate-badge]][donate]

6. **ACRONYM**: If the item's acronym is the given value (ex. `us` would match `United States`)
7. **SIMPLE MATCH**: If the item has letters in the same order as the letters of the given value (ex. `iw` would match `Zimbabwe`, but not `Kuwait` because it must be in the same order).
7. **SIMPLE MATCH**: If the item has letters in the same order as the letters of the given value (ex. `iw` would match `Zimbabwe`, but not `Kuwait` because it must be in the same order). Furthermore, if the item is a closer match, it will rank higher (ex. `ua` matches `Uruguay` more closely than `United States of America`, therefore `Uruguay` will be ordered before `United States of America`)

@@ -87,6 +87,6 @@ This ranking seems to make sense in people's minds. At least it does in mine. Feedback welcome!

matchSorter(objList, 'g', {keys: ['name', 'color']})
// [{name: 'George', color: 'Blue'}, {name: 'Janice', color: 'Green'}]
// [{name: 'George', color: 'Blue'}, {name: 'Janice', color: 'Green'}, {name: 'Fred', color: 'Orange'}]
matchSorter(objList, 're', {keys: ['color', 'name']})
// [{name: 'Jen', color: 'Red'}, {name: 'Janice', color: 'Green'}, {name: 'Fred', color: 'Orange'}]
// [{name: 'Jen', color: 'Red'}, {name: 'Janice', color: 'Green'}, {name: 'Fred', color: 'Orange'}, {name: 'George', color: 'Blue'}]
```

@@ -199,3 +199,3 @@

matchSorter(thingsWithDiacritics, 'aa')
// ['jalapeño', 'à la carte', 'papier-mâché', 'à la mode']
// ['jalapeño', 'à la carte', 'à la mode', 'papier-mâché']

@@ -228,4 +228,4 @@ matchSorter(thingsWithDiacritics, 'aa', {keepDiacritics: true})

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) 🚇 [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) 👀 | [<img src="https://avatars.githubusercontent.com/u/8263298?v=3" width="100px;"/><br /><sub>Conor Hastings</sub>](http://conorhastings.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) [📖](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) 👀 | [<img src="https://avatars.githubusercontent.com/u/574806?v=3" width="100px;"/><br /><sub>Rogelio Guzman</sub>](https://github.com/rogeliog)<br />[📖](https://github.com/kentcdodds/match-sorter/commits?author=rogeliog) | [<img src="https://avatars.githubusercontent.com/u/1416436?v=3" width="100px;"/><br /><sub>Claudéric Demers</sub>](http://ced.io)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=clauderic) [📖](https://github.com/kentcdodds/match-sorter/commits?author=clauderic) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=clauderic) | [<img src="https://avatars1.githubusercontent.com/u/19157735?v=3" width="100px;"/><br /><sub>Denver Chen</sub>](https://github.com/nfdjps)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps) [📖](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps) |
| :---: | :---: | :---: | :---: | :---: |
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub>Kent C. Dodds</sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) [📖](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) 🚇 [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds) 👀 | [<img src="https://avatars.githubusercontent.com/u/8263298?v=3" width="100px;"/><br /><sub>Conor Hastings</sub>](http://conorhastings.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) [📖](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings) 👀 | [<img src="https://avatars.githubusercontent.com/u/574806?v=3" width="100px;"/><br /><sub>Rogelio Guzman</sub>](https://github.com/rogeliog)<br />[📖](https://github.com/kentcdodds/match-sorter/commits?author=rogeliog) | [<img src="https://avatars.githubusercontent.com/u/1416436?v=3" width="100px;"/><br /><sub>Claudéric Demers</sub>](http://ced.io)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=clauderic) [📖](https://github.com/kentcdodds/match-sorter/commits?author=clauderic) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=clauderic) | [<img src="https://avatars3.githubusercontent.com/u/4150097?v=3" width="100px;"/><br /><sub>Kevin Davis</sub>](kevindav.us)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=osfan501) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=osfan501) | [<img src="https://avatars1.githubusercontent.com/u/19157735?v=3" width="100px;"/><br /><sub>Denver Chen</sub>](https://github.com/nfdjps)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps) [📖](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps) [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps) |
| :---: | :---: | :---: | :---: | :---: | :---: |
<!-- ALL-CONTRIBUTORS-LIST:END -->

@@ -232,0 +232,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc