match-sorter
Advanced tools
Comparing version 3.0.1 to 3.1.0
@@ -495,2 +495,3 @@ 'use strict'; | ||
var _getHighestRanking = getHighestRanking(item, keys, value, options), | ||
rankedItem = _getHighestRanking.rankedItem, | ||
rank = _getHighestRanking.rank, | ||
@@ -502,3 +503,3 @@ keyIndex = _getHighestRanking.keyIndex, | ||
if (rank >= keyThreshold) { | ||
matches.push({ item: item, rank: rank, index: index, keyIndex: keyIndex }); | ||
matches.push({ rankedItem: rankedItem, item: item, rank: rank, index: index, keyIndex: keyIndex }); | ||
} | ||
@@ -524,2 +525,4 @@ return matches; | ||
return { | ||
// ends up being duplicate of 'item' in matches but consistent | ||
rankedItem: item, | ||
rank: getMatchRanking(item, value, options), | ||
@@ -553,3 +556,3 @@ keyIndex: -1, | ||
} | ||
return { rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold }; | ||
return { rankedItem: itemValue, rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold }; | ||
}, { rank: rankings.NO_MATCH, keyIndex: -1, keyThreshold: options.threshold }); | ||
@@ -770,4 +773,4 @@ } | ||
var inOrderPercentage = matchingInOrderCharCount / stringToRank.length; | ||
return 1 + inOrderPercentage * (1 / spread); | ||
var ranking = rankings.MATCHES + inOrderPercentage * (1 / spread); | ||
return ranking; | ||
} | ||
@@ -802,7 +805,7 @@ var firstIndex = findMatchingCharacter(stringToRank[0], testString, 0); | ||
var bFirst = 1; | ||
var aRank = a.rank, | ||
aIndex = a.index, | ||
var aRankedItem = a.rankedItem, | ||
aRank = a.rank, | ||
aKeyIndex = a.keyIndex; | ||
var bRank = b.rank, | ||
bIndex = b.index, | ||
var bRankedItem = b.rankedItem, | ||
bRank = b.rank, | ||
bKeyIndex = b.keyIndex; | ||
@@ -812,3 +815,3 @@ | ||
if (aKeyIndex === bKeyIndex) { | ||
return aIndex < bIndex ? aFirst : bFirst; | ||
return aRankedItem.localeCompare(bRankedItem); | ||
} else { | ||
@@ -815,0 +818,0 @@ return aKeyIndex < bKeyIndex ? aFirst : bFirst; |
@@ -493,2 +493,3 @@ var characterMap = { | ||
var _getHighestRanking = getHighestRanking(item, keys, value, options), | ||
rankedItem = _getHighestRanking.rankedItem, | ||
rank = _getHighestRanking.rank, | ||
@@ -500,3 +501,3 @@ keyIndex = _getHighestRanking.keyIndex, | ||
if (rank >= keyThreshold) { | ||
matches.push({ item: item, rank: rank, index: index, keyIndex: keyIndex }); | ||
matches.push({ rankedItem: rankedItem, item: item, rank: rank, index: index, keyIndex: keyIndex }); | ||
} | ||
@@ -522,2 +523,4 @@ return matches; | ||
return { | ||
// ends up being duplicate of 'item' in matches but consistent | ||
rankedItem: item, | ||
rank: getMatchRanking(item, value, options), | ||
@@ -551,3 +554,3 @@ keyIndex: -1, | ||
} | ||
return { rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold }; | ||
return { rankedItem: itemValue, rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold }; | ||
}, { rank: rankings.NO_MATCH, keyIndex: -1, keyThreshold: options.threshold }); | ||
@@ -768,4 +771,4 @@ } | ||
var inOrderPercentage = matchingInOrderCharCount / stringToRank.length; | ||
return 1 + inOrderPercentage * (1 / spread); | ||
var ranking = rankings.MATCHES + inOrderPercentage * (1 / spread); | ||
return ranking; | ||
} | ||
@@ -800,7 +803,7 @@ var firstIndex = findMatchingCharacter(stringToRank[0], testString, 0); | ||
var bFirst = 1; | ||
var aRank = a.rank, | ||
aIndex = a.index, | ||
var aRankedItem = a.rankedItem, | ||
aRank = a.rank, | ||
aKeyIndex = a.keyIndex; | ||
var bRank = b.rank, | ||
bIndex = b.index, | ||
var bRankedItem = b.rankedItem, | ||
bRank = b.rank, | ||
bKeyIndex = b.keyIndex; | ||
@@ -810,3 +813,3 @@ | ||
if (aKeyIndex === bKeyIndex) { | ||
return aIndex < bIndex ? aFirst : bFirst; | ||
return aRankedItem.localeCompare(bRankedItem); | ||
} else { | ||
@@ -813,0 +816,0 @@ return aKeyIndex < bKeyIndex ? aFirst : bFirst; |
@@ -499,2 +499,3 @@ (function (global, factory) { | ||
var _getHighestRanking = getHighestRanking(item, keys, value, options), | ||
rankedItem = _getHighestRanking.rankedItem, | ||
rank = _getHighestRanking.rank, | ||
@@ -506,3 +507,3 @@ keyIndex = _getHighestRanking.keyIndex, | ||
if (rank >= keyThreshold) { | ||
matches.push({ item: item, rank: rank, index: index, keyIndex: keyIndex }); | ||
matches.push({ rankedItem: rankedItem, item: item, rank: rank, index: index, keyIndex: keyIndex }); | ||
} | ||
@@ -528,2 +529,4 @@ return matches; | ||
return { | ||
// ends up being duplicate of 'item' in matches but consistent | ||
rankedItem: item, | ||
rank: getMatchRanking(item, value, options), | ||
@@ -557,3 +560,3 @@ keyIndex: -1, | ||
} | ||
return { rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold }; | ||
return { rankedItem: itemValue, rank: rank, keyIndex: keyIndex, keyThreshold: keyThreshold }; | ||
}, { rank: rankings.NO_MATCH, keyIndex: -1, keyThreshold: options.threshold }); | ||
@@ -774,4 +777,4 @@ } | ||
var inOrderPercentage = matchingInOrderCharCount / stringToRank.length; | ||
return 1 + inOrderPercentage * (1 / spread); | ||
var ranking = rankings.MATCHES + inOrderPercentage * (1 / spread); | ||
return ranking; | ||
} | ||
@@ -806,7 +809,7 @@ var firstIndex = findMatchingCharacter(stringToRank[0], testString, 0); | ||
var bFirst = 1; | ||
var aRank = a.rank, | ||
aIndex = a.index, | ||
var aRankedItem = a.rankedItem, | ||
aRank = a.rank, | ||
aKeyIndex = a.keyIndex; | ||
var bRank = b.rank, | ||
bIndex = b.index, | ||
var bRankedItem = b.rankedItem, | ||
bRank = b.rank, | ||
bKeyIndex = b.keyIndex; | ||
@@ -816,3 +819,3 @@ | ||
if (aKeyIndex === bKeyIndex) { | ||
return aIndex < bIndex ? aFirst : bFirst; | ||
return aRankedItem.localeCompare(bRankedItem); | ||
} else { | ||
@@ -819,0 +822,0 @@ return aKeyIndex < bKeyIndex ? aFirst : bFirst; |
@@ -1,2 +0,2 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.matchSorter=n()}(this,function(){"use strict";var e={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ấ":"A","Ắ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Æ":"AE","Ầ":"A","Ằ":"A","Ȃ":"A","Ç":"C","Ḉ":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ế":"E","Ḗ":"E","Ề":"E","Ḕ":"E","Ḝ":"E","Ȇ":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ḯ":"I","Ȋ":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ố":"O","Ṍ":"O","Ṓ":"O","Ȏ":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ấ":"a","ắ":"a","ẳ":"a","ẵ":"a","ặ":"a","æ":"ae","ầ":"a","ằ":"a","ȃ":"a","ç":"c","ḉ":"c","è":"e","é":"e","ê":"e","ë":"e","ế":"e","ḗ":"e","ề":"e","ḕ":"e","ḝ":"e","ȇ":"e","ì":"i","í":"i","î":"i","ï":"i","ḯ":"i","ȋ":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ố":"o","ṍ":"o","ṓ":"o","ȏ":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","C̆":"C","c̆":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","Ǵ":"G","ĝ":"g","ǵ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ḫ":"H","ḫ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ḱ":"K","ḱ":"k","K̆":"K","k̆":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ḿ":"M","ḿ":"m","M̆":"M","m̆":"m","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","N̆":"N","n̆":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","P̆":"P","p̆":"p","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","R̆":"R","r̆":"r","Ȓ":"R","ȓ":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","Ș":"S","ș":"s","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","ț":"t","Ț":"T","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","T̆":"T","t̆":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ȗ":"U","ȗ":"u","V̆":"V","v̆":"v","Ŵ":"W","ŵ":"w","Ẃ":"W","ẃ":"w","X̆":"X","x̆":"x","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Y̆":"Y","y̆":"y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ứ":"U","ứ":"u","Ṹ":"U","ṹ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o","Þ":"TH","þ":"th","Ṕ":"P","ṕ":"p","Ṥ":"S","ṥ":"s","X́":"X","x́":"x","Ѓ":"Г","ѓ":"г","Ќ":"К","ќ":"к","A̋":"A","a̋":"a","E̋":"E","e̋":"e","I̋":"I","i̋":"i","Ǹ":"N","ǹ":"n","Ồ":"O","ồ":"o","Ṑ":"O","ṑ":"o","Ừ":"U","ừ":"u","Ẁ":"W","ẁ":"w","Ỳ":"Y","ỳ":"y","Ȁ":"A","ȁ":"a","Ȅ":"E","ȅ":"e","Ȉ":"I","ȉ":"i","Ȍ":"O","ȍ":"o","Ȑ":"R","ȑ":"r","Ȕ":"U","ȕ":"u","B̌":"B","b̌":"b","Č̣":"C","č̣":"c","Ê̌":"E","ê̌":"e","F̌":"F","f̌":"f","Ǧ":"G","ǧ":"g","Ȟ":"H","ȟ":"h","J̌":"J","ǰ":"j","Ǩ":"K","ǩ":"k","M̌":"M","m̌":"m","P̌":"P","p̌":"p","Q̌":"Q","q̌":"q","Ř̩":"R","ř̩":"r","Ṧ":"S","ṧ":"s","V̌":"V","v̌":"v","W̌":"W","w̌":"w","X̌":"X","x̌":"x","Y̌":"Y","y̌":"y","A̧":"A","a̧":"a","B̧":"B","b̧":"b","Ḑ":"D","ḑ":"d","Ȩ":"E","ȩ":"e","Ɛ̧":"E","ɛ̧":"e","Ḩ":"H","ḩ":"h","I̧":"I","i̧":"i","Ɨ̧":"I","ɨ̧":"i","M̧":"M","m̧":"m","O̧":"O","o̧":"o","Q̧":"Q","q̧":"q","U̧":"U","u̧":"u","X̧":"X","x̧":"x","Z̧":"Z","z̧":"z"},n=Object.keys(e).join("|"),r=new RegExp(n,"g"),t=new RegExp(n,""),o=function(n){return n.replace(r,function(n){return e[n]})},u=o,i=function(e){return!!e.match(t)},a=o;u.has=i,u.remove=a;var c="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},f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},A={CASE_SENSITIVE_EQUAL:9,EQUAL:8,STARTS_WITH:7,WORD_STARTS_WITH:6,STRING_CASE:5,STRING_CASE_ACRONYM:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},s={CAMEL:.8,PASCAL:.6,KEBAB:.4,SNAKE:.2,NO_CASE:0};function E(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n)return e;var t=r.keys,o=r.threshold,u=void 0===o?A.MATCHES:o;return e.reduce(function(e,o,i){var a=function(e,n,r,t){if(!n)return{rank:d(e,r,t),keyIndex:-1,keyThreshold:t.threshold};return function(e,n){return n.reduce(function(n,r){var t=function(e,n){"object"===(void 0===n?"undefined":c(n))&&(n=n.key);var r=void 0;r="function"==typeof n?n(e):-1!==n.indexOf(".")?n.split(".").reduce(function(e,n){return e?e[n]:null},e):e[n];return null!=r?[].concat(r):null}(e,r);return t&&t.forEach(function(e){n.push({itemValue:e,attributes:function(e){"string"==typeof e&&(e={key:e});return f({maxRanking:1/0,minRanking:-1/0},e)}(r)})}),n},[])}(e,n).reduce(function(e,n,o){var u=e.rank,i=e.keyIndex,a=e.keyThreshold,c=n.itemValue,f=n.attributes,s=d(c,r,t),E=f.minRanking,l=f.maxRanking,O=f.threshold;return s<E&&s>=A.MATCHES?s=E:s>l&&(s=l),s>u&&(u=s,i=o,a=O),{rank:u,keyIndex:i,keyThreshold:a}},{rank:A.NO_MATCH,keyIndex:-1,keyThreshold:t.threshold})}(o,t,n,r),s=a.rank,E=a.keyIndex,l=a.keyThreshold;return s>=(void 0===l?u:l)&&e.push({item:o,rank:s,index:i,keyIndex:E}),e},[]).sort(l).map(function(e){return e.item})}function d(e,n,r){if(e=O(e,r),(n=O(n,r)).length>e.length)return A.NO_MATCH;if(e===n)return A.CASE_SENSITIVE_EQUAL;var t,o,u=function(e){var n=e.toLowerCase()!==e,r=e.indexOf("-")>=0,t=e.indexOf("_")>=0;if(!n&&!t&&r)return s.KEBAB;if(!n&&t&&!r)return s.SNAKE;if(n&&!r&&!t){var o=e[0].toUpperCase()===e[0];return o?s.PASCAL:s.CAMEL}return s.NO_CASE}(e),i=function(e,n,r){var t=e.toLowerCase().indexOf(n.toLowerCase());switch(r){case s.SNAKE:return"_"===e[t-1];case s.KEBAB:return"-"===e[t-1];case s.PASCAL:case s.CAMEL:return-1!==t&&e[t]===e[t].toUpperCase();default:return!1}}(e,n,u),a=function(e,n,r){var t=null;switch(r){case s.SNAKE:t="_";break;case s.KEBAB:t="-";break;case s.PASCAL:case s.CAMEL:t=/(?=[A-Z])/;break;default:t=null}var o=e.split(t);return n.toLowerCase().split("").reduce(function(e,n,r){var t=o[r];return e&&t&&t[0].toLowerCase()===n},!0)}(e,n,u);return(e=e.toLowerCase())===(n=n.toLowerCase())?A.EQUAL+u:0===e.indexOf(n)?A.STARTS_WITH+u:-1!==e.indexOf(" "+n)?A.WORD_STARTS_WITH+u:i?A.STRING_CASE+u:u>0&&a?A.STRING_CASE_ACRONYM+u:-1!==e.indexOf(n)?A.CONTAINS+u:1===n.length?A.NO_MATCH:-1!==(t=e,o="",t.split(" ").forEach(function(e){e.split("-").forEach(function(e){o+=e.substr(0,1)})}),o).indexOf(n)?A.ACRONYM+u:function(e,n){var r=0,t=0;function o(e,n,t){for(var o=t;o<n.length;o++){var u=n[o];if(u===e)return r+=1,o+1}return-1}var u=o(n[0],e,0);if(u<0)return A.NO_MATCH;t=u;for(var i=1;i<n.length;i++){var a=n[i],c=(t=o(a,e,t))>-1;if(!c)return A.NO_MATCH}return function(e){return 1+r/n.length*(1/e)}(t-u)}(e,n)}function l(e,n){var r=e.rank,t=e.index,o=e.keyIndex,u=n.rank,i=n.index,a=n.keyIndex;return r===u?o===a?t<i?-1:1:o<a?-1:1:r>u?-1:1}function O(e,n){return e=""+e,n.keepDiacritics||(e=u(e)),e}E.rankings=A,E.caseRankings=s;var S=Object.freeze({default:E,rankings:A}),C=E;return Object.assign(C,Object.keys(S).reduce(function(e,n){return"default"!==n&&(e[n]=S[n]),e},{})),C}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):e.matchSorter=n()}(this,function(){"use strict";var e={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Ấ":"A","Ắ":"A","Ẳ":"A","Ẵ":"A","Ặ":"A","Æ":"AE","Ầ":"A","Ằ":"A","Ȃ":"A","Ç":"C","Ḉ":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ế":"E","Ḗ":"E","Ề":"E","Ḕ":"E","Ḝ":"E","Ȇ":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ḯ":"I","Ȋ":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ố":"O","Ṍ":"O","Ṓ":"O","Ȏ":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","ấ":"a","ắ":"a","ẳ":"a","ẵ":"a","ặ":"a","æ":"ae","ầ":"a","ằ":"a","ȃ":"a","ç":"c","ḉ":"c","è":"e","é":"e","ê":"e","ë":"e","ế":"e","ḗ":"e","ề":"e","ḕ":"e","ḝ":"e","ȇ":"e","ì":"i","í":"i","î":"i","ï":"i","ḯ":"i","ȋ":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ố":"o","ṍ":"o","ṓ":"o","ȏ":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Ĉ":"C","ĉ":"c","Ċ":"C","ċ":"c","Č":"C","č":"c","C̆":"C","c̆":"c","Ď":"D","ď":"d","Đ":"D","đ":"d","Ē":"E","ē":"e","Ĕ":"E","ĕ":"e","Ė":"E","ė":"e","Ę":"E","ę":"e","Ě":"E","ě":"e","Ĝ":"G","Ǵ":"G","ĝ":"g","ǵ":"g","Ğ":"G","ğ":"g","Ġ":"G","ġ":"g","Ģ":"G","ģ":"g","Ĥ":"H","ĥ":"h","Ħ":"H","ħ":"h","Ḫ":"H","ḫ":"h","Ĩ":"I","ĩ":"i","Ī":"I","ī":"i","Ĭ":"I","ĭ":"i","Į":"I","į":"i","İ":"I","ı":"i","IJ":"IJ","ij":"ij","Ĵ":"J","ĵ":"j","Ķ":"K","ķ":"k","Ḱ":"K","ḱ":"k","K̆":"K","k̆":"k","Ĺ":"L","ĺ":"l","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ŀ":"L","ŀ":"l","Ł":"l","ł":"l","Ḿ":"M","ḿ":"m","M̆":"M","m̆":"m","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","ʼn":"n","N̆":"N","n̆":"n","Ō":"O","ō":"o","Ŏ":"O","ŏ":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","P̆":"P","p̆":"p","Ŕ":"R","ŕ":"r","Ŗ":"R","ŗ":"r","Ř":"R","ř":"r","R̆":"R","r̆":"r","Ȓ":"R","ȓ":"r","Ś":"S","ś":"s","Ŝ":"S","ŝ":"s","Ş":"S","Ș":"S","ș":"s","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","ț":"t","Ț":"T","Ť":"T","ť":"t","Ŧ":"T","ŧ":"t","T̆":"T","t̆":"t","Ũ":"U","ũ":"u","Ū":"U","ū":"u","Ŭ":"U","ŭ":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ȗ":"U","ȗ":"u","V̆":"V","v̆":"v","Ŵ":"W","ŵ":"w","Ẃ":"W","ẃ":"w","X̆":"X","x̆":"x","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Y̆":"Y","y̆":"y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","ſ":"s","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Ǎ":"A","ǎ":"a","Ǐ":"I","ǐ":"i","Ǒ":"O","ǒ":"o","Ǔ":"U","ǔ":"u","Ǖ":"U","ǖ":"u","Ǘ":"U","ǘ":"u","Ǚ":"U","ǚ":"u","Ǜ":"U","ǜ":"u","Ứ":"U","ứ":"u","Ṹ":"U","ṹ":"u","Ǻ":"A","ǻ":"a","Ǽ":"AE","ǽ":"ae","Ǿ":"O","ǿ":"o","Þ":"TH","þ":"th","Ṕ":"P","ṕ":"p","Ṥ":"S","ṥ":"s","X́":"X","x́":"x","Ѓ":"Г","ѓ":"г","Ќ":"К","ќ":"к","A̋":"A","a̋":"a","E̋":"E","e̋":"e","I̋":"I","i̋":"i","Ǹ":"N","ǹ":"n","Ồ":"O","ồ":"o","Ṑ":"O","ṑ":"o","Ừ":"U","ừ":"u","Ẁ":"W","ẁ":"w","Ỳ":"Y","ỳ":"y","Ȁ":"A","ȁ":"a","Ȅ":"E","ȅ":"e","Ȉ":"I","ȉ":"i","Ȍ":"O","ȍ":"o","Ȑ":"R","ȑ":"r","Ȕ":"U","ȕ":"u","B̌":"B","b̌":"b","Č̣":"C","č̣":"c","Ê̌":"E","ê̌":"e","F̌":"F","f̌":"f","Ǧ":"G","ǧ":"g","Ȟ":"H","ȟ":"h","J̌":"J","ǰ":"j","Ǩ":"K","ǩ":"k","M̌":"M","m̌":"m","P̌":"P","p̌":"p","Q̌":"Q","q̌":"q","Ř̩":"R","ř̩":"r","Ṧ":"S","ṧ":"s","V̌":"V","v̌":"v","W̌":"W","w̌":"w","X̌":"X","x̌":"x","Y̌":"Y","y̌":"y","A̧":"A","a̧":"a","B̧":"B","b̧":"b","Ḑ":"D","ḑ":"d","Ȩ":"E","ȩ":"e","Ɛ̧":"E","ɛ̧":"e","Ḩ":"H","ḩ":"h","I̧":"I","i̧":"i","Ɨ̧":"I","ɨ̧":"i","M̧":"M","m̧":"m","O̧":"O","o̧":"o","Q̧":"Q","q̧":"q","U̧":"U","u̧":"u","X̧":"X","x̧":"x","Z̧":"Z","z̧":"z"},n=Object.keys(e).join("|"),r=new RegExp(n,"g"),t=new RegExp(n,""),o=function(n){return n.replace(r,function(n){return e[n]})},u=o,a=function(e){return!!e.match(t)},i=o;u.has=a,u.remove=i;var c="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},f=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var t in r)Object.prototype.hasOwnProperty.call(r,t)&&(e[t]=r[t])}return e},A={CASE_SENSITIVE_EQUAL:9,EQUAL:8,STARTS_WITH:7,WORD_STARTS_WITH:6,STRING_CASE:5,STRING_CASE_ACRONYM:4,CONTAINS:3,ACRONYM:2,MATCHES:1,NO_MATCH:0},s={CAMEL:.8,PASCAL:.6,KEBAB:.4,SNAKE:.2,NO_CASE:0};function d(e,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!n)return e;var t=r.keys,o=r.threshold,u=void 0===o?A.MATCHES:o;return e.reduce(function(e,o,a){var i=function(e,n,r,t){if(!n)return{rankedItem:e,rank:E(e,r,t),keyIndex:-1,keyThreshold:t.threshold};return function(e,n){return n.reduce(function(n,r){var t=function(e,n){"object"===(void 0===n?"undefined":c(n))&&(n=n.key);var r=void 0;r="function"==typeof n?n(e):-1!==n.indexOf(".")?n.split(".").reduce(function(e,n){return e?e[n]:null},e):e[n];return null!=r?[].concat(r):null}(e,r);return t&&t.forEach(function(e){n.push({itemValue:e,attributes:function(e){"string"==typeof e&&(e={key:e});return f({maxRanking:1/0,minRanking:-1/0},e)}(r)})}),n},[])}(e,n).reduce(function(e,n,o){var u=e.rank,a=e.keyIndex,i=e.keyThreshold,c=n.itemValue,f=n.attributes,s=E(c,r,t),d=f.minRanking,l=f.maxRanking,O=f.threshold;return s<d&&s>=A.MATCHES?s=d:s>l&&(s=l),s>u&&(u=s,a=o,i=O),{rankedItem:c,rank:u,keyIndex:a,keyThreshold:i}},{rank:A.NO_MATCH,keyIndex:-1,keyThreshold:t.threshold})}(o,t,n,r),s=i.rankedItem,d=i.rank,l=i.keyIndex,O=i.keyThreshold;return d>=(void 0===O?u:O)&&e.push({rankedItem:s,item:o,rank:d,index:a,keyIndex:l}),e},[]).sort(l).map(function(e){return e.item})}function E(e,n,r){if(e=O(e,r),(n=O(n,r)).length>e.length)return A.NO_MATCH;if(e===n)return A.CASE_SENSITIVE_EQUAL;var t,o,u=function(e){var n=e.toLowerCase()!==e,r=e.indexOf("-")>=0,t=e.indexOf("_")>=0;if(!n&&!t&&r)return s.KEBAB;if(!n&&t&&!r)return s.SNAKE;if(n&&!r&&!t){var o=e[0].toUpperCase()===e[0];return o?s.PASCAL:s.CAMEL}return s.NO_CASE}(e),a=function(e,n,r){var t=e.toLowerCase().indexOf(n.toLowerCase());switch(r){case s.SNAKE:return"_"===e[t-1];case s.KEBAB:return"-"===e[t-1];case s.PASCAL:case s.CAMEL:return-1!==t&&e[t]===e[t].toUpperCase();default:return!1}}(e,n,u),i=function(e,n,r){var t=null;switch(r){case s.SNAKE:t="_";break;case s.KEBAB:t="-";break;case s.PASCAL:case s.CAMEL:t=/(?=[A-Z])/;break;default:t=null}var o=e.split(t);return n.toLowerCase().split("").reduce(function(e,n,r){var t=o[r];return e&&t&&t[0].toLowerCase()===n},!0)}(e,n,u);return(e=e.toLowerCase())===(n=n.toLowerCase())?A.EQUAL+u:0===e.indexOf(n)?A.STARTS_WITH+u:-1!==e.indexOf(" "+n)?A.WORD_STARTS_WITH+u:a?A.STRING_CASE+u:u>0&&i?A.STRING_CASE_ACRONYM+u:-1!==e.indexOf(n)?A.CONTAINS+u:1===n.length?A.NO_MATCH:-1!==(t=e,o="",t.split(" ").forEach(function(e){e.split("-").forEach(function(e){o+=e.substr(0,1)})}),o).indexOf(n)?A.ACRONYM+u:function(e,n){var r=0,t=0;function o(e,n,t){for(var o=t;o<n.length;o++){var u=n[o];if(u===e)return r+=1,o+1}return-1}var u=o(n[0],e,0);if(u<0)return A.NO_MATCH;t=u;for(var a=1;a<n.length;a++){var i=n[a],c=(t=o(i,e,t))>-1;if(!c)return A.NO_MATCH}return function(e){var t=r/n.length;return A.MATCHES+t*(1/e)}(t-u)}(e,n)}function l(e,n){var r=e.rankedItem,t=e.rank,o=e.keyIndex,u=n.rankedItem,a=n.rank,i=n.keyIndex;return t===a?o===i?r.localeCompare(u):o<i?-1:1:t>a?-1:1}function O(e,n){return e=""+e,n.keepDiacritics||(e=u(e)),e}d.rankings=A,d.caseRankings=s;var C=Object.freeze({default:d,rankings:A}),S=d;return Object.assign(S,Object.keys(C).reduce(function(e,n){return"default"!==n&&(e[n]=C[n]),e},{})),S}); | ||
//# sourceMappingURL=match-sorter.umd.min.js.map |
{ | ||
"name": "match-sorter", | ||
"version": "3.0.1", | ||
"version": "3.1.0", | ||
"description": "Simple, expected, and deterministic best-match sorting of an array in JavaScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/match-sorter.cjs.js", |
@@ -18,3 +18,3 @@ <div align="center"> | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors) | ||
[![PRs Welcome][prs-badge]][prs] | ||
@@ -283,5 +283,3 @@ [![Donate][donate-badge]][donate] | ||
<!-- prettier-ignore --> | ||
| [<img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;"/><br /><sub><b>Kent C. Dodds</b></sub>](https://kentcdodds.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds "Code") [📖](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds "Documentation") [🚇](#infra-kentcdodds "Infrastructure (Hosting, Build-Tools, etc)") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds "Tests") [👀](#review-kentcdodds "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/8263298?v=3" width="100px;"/><br /><sub><b>Conor Hastings</b></sub>](http://conorhastings.com)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings "Code") [📖](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings "Documentation") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=conorhastings "Tests") [👀](#review-conorhastings "Reviewed Pull Requests") | [<img src="https://avatars.githubusercontent.com/u/574806?v=3" width="100px;"/><br /><sub><b>Rogelio Guzman</b></sub>](https://github.com/rogeliog)<br />[📖](https://github.com/kentcdodds/match-sorter/commits?author=rogeliog "Documentation") | [<img src="https://avatars.githubusercontent.com/u/1416436?v=3" width="100px;"/><br /><sub><b>Claudéric Demers</b></sub>](http://ced.io)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=clauderic "Code") [📖](https://github.com/kentcdodds/match-sorter/commits?author=clauderic "Documentation") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=clauderic "Tests") | [<img src="https://avatars3.githubusercontent.com/u/4150097?v=3" width="100px;"/><br /><sub><b>Kevin Davis</b></sub>](kevindav.us)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=osfan501 "Code") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=osfan501 "Tests") | [<img src="https://avatars1.githubusercontent.com/u/19157735?v=3" width="100px;"/><br /><sub><b>Denver Chen</b></sub>](https://github.com/nfdjps)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps "Code") [📖](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps "Documentation") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=nfdjps "Tests") | [<img src="https://avatars0.githubusercontent.com/u/12719057?v=4" width="100px;"/><br /><sub><b>Christian Ruigrok</b></sub>](http://ruigrok.info)<br />[🐛](https://github.com/kentcdodds/match-sorter/issues?q=author%3AChrisRu "Bug reports") [💻](https://github.com/kentcdodds/match-sorter/commits?author=ChrisRu "Code") [📖](https://github.com/kentcdodds/match-sorter/commits?author=ChrisRu "Documentation") | | ||
| :---: | :---: | :---: | :---: | :---: | :---: | :---: | | ||
| [<img src="https://avatars1.githubusercontent.com/u/2084833?v=4" width="100px;"/><br /><sub><b>Hozefa</b></sub>](https://github.com/hozefaj)<br />[🐛](https://github.com/kentcdodds/match-sorter/issues?q=author%3Ahozefaj "Bug reports") [💻](https://github.com/kentcdodds/match-sorter/commits?author=hozefaj "Code") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=hozefaj "Tests") [🤔](#ideas-hozefaj "Ideas, Planning, & Feedback") | [<img src="https://avatars3.githubusercontent.com/u/9403361?v=4" width="100px;"/><br /><sub><b>pushpinder107</b></sub>](https://github.com/pushpinder107)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=pushpinder107 "Code") | [<img src="https://avatars3.githubusercontent.com/u/200528?v=4" width="100px;"/><br /><sub><b>Mordy Tikotzky</b></sub>](https://github.com/tikotzky)<br />[💻](https://github.com/kentcdodds/match-sorter/commits?author=tikotzky "Code") [📖](https://github.com/kentcdodds/match-sorter/commits?author=tikotzky "Documentation") [⚠️](https://github.com/kentcdodds/match-sorter/commits?author=tikotzky "Tests") | | ||
<table><tr><td align="center"><a href="https://kentcdodds.com"><img src="https://avatars.githubusercontent.com/u/1500684?v=3" width="100px;" alt="Kent C. Dodds"/><br /><sub><b>Kent C. Dodds</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds" title="Documentation">📖</a> <a href="#infra-kentcdodds" title="Infrastructure (Hosting, Build-Tools, etc)">🚇</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=kentcdodds" title="Tests">⚠️</a> <a href="#review-kentcdodds" title="Reviewed Pull Requests">👀</a></td><td align="center"><a href="http://conorhastings.com"><img src="https://avatars.githubusercontent.com/u/8263298?v=3" width="100px;" alt="Conor Hastings"/><br /><sub><b>Conor Hastings</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=conorhastings" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=conorhastings" title="Documentation">📖</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=conorhastings" title="Tests">⚠️</a> <a href="#review-conorhastings" title="Reviewed Pull Requests">👀</a></td><td align="center"><a href="https://github.com/rogeliog"><img src="https://avatars.githubusercontent.com/u/574806?v=3" width="100px;" alt="Rogelio Guzman"/><br /><sub><b>Rogelio Guzman</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=rogeliog" title="Documentation">📖</a></td><td align="center"><a href="http://ced.io"><img src="https://avatars.githubusercontent.com/u/1416436?v=3" width="100px;" alt="Claudéric Demers"/><br /><sub><b>Claudéric Demers</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=clauderic" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=clauderic" title="Documentation">📖</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=clauderic" title="Tests">⚠️</a></td><td align="center"><a href="kevindav.us"><img src="https://avatars3.githubusercontent.com/u/4150097?v=3" width="100px;" alt="Kevin Davis"/><br /><sub><b>Kevin Davis</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=osfan501" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=osfan501" title="Tests">⚠️</a></td><td align="center"><a href="https://github.com/nfdjps"><img src="https://avatars1.githubusercontent.com/u/19157735?v=3" width="100px;" alt="Denver Chen"/><br /><sub><b>Denver Chen</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=nfdjps" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=nfdjps" title="Documentation">📖</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=nfdjps" title="Tests">⚠️</a></td><td align="center"><a href="http://ruigrok.info"><img src="https://avatars0.githubusercontent.com/u/12719057?v=4" width="100px;" alt="Christian Ruigrok"/><br /><sub><b>Christian Ruigrok</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/issues?q=author%3AChrisRu" title="Bug reports">🐛</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=ChrisRu" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=ChrisRu" title="Documentation">📖</a></td></tr><tr><td align="center"><a href="https://github.com/hozefaj"><img src="https://avatars1.githubusercontent.com/u/2084833?v=4" width="100px;" alt="Hozefa"/><br /><sub><b>Hozefa</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/issues?q=author%3Ahozefaj" title="Bug reports">🐛</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=hozefaj" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=hozefaj" title="Tests">⚠️</a> <a href="#ideas-hozefaj" title="Ideas, Planning, & Feedback">🤔</a></td><td align="center"><a href="https://github.com/pushpinder107"><img src="https://avatars3.githubusercontent.com/u/9403361?v=4" width="100px;" alt="pushpinder107"/><br /><sub><b>pushpinder107</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=pushpinder107" title="Code">💻</a></td><td align="center"><a href="https://github.com/tikotzky"><img src="https://avatars3.githubusercontent.com/u/200528?v=4" width="100px;" alt="Mordy Tikotzky"/><br /><sub><b>Mordy Tikotzky</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=tikotzky" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=tikotzky" title="Documentation">📖</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=tikotzky" title="Tests">⚠️</a></td><td align="center"><a href="https://github.com/sdbrannum"><img src="https://avatars1.githubusercontent.com/u/11765845?v=4" width="100px;" alt="Steven Brannum"/><br /><sub><b>Steven Brannum</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/commits?author=sdbrannum" title="Code">💻</a> <a href="https://github.com/kentcdodds/match-sorter/commits?author=sdbrannum" title="Tests">⚠️</a></td><td align="center"><a href="https://github.com/cmeeren"><img src="https://avatars0.githubusercontent.com/u/7766733?v=4" width="100px;" alt="Christer van der Meeren"/><br /><sub><b>Christer van der Meeren</b></sub></a><br /><a href="https://github.com/kentcdodds/match-sorter/issues?q=author%3Acmeeren" title="Bug reports">🐛</a></td></tr></table> | ||
@@ -288,0 +286,0 @@ <!-- ALL-CONTRIBUTORS-LIST:END --> |
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
185416
3042
330