match-sorter
Advanced tools
Comparing version 1.4.1 to 1.5.0
@@ -241,6 +241,9 @@ 'use strict'; | ||
* @param {Object} item - the item | ||
* @param {Object} key - the potentially nested keypath | ||
* @param {Object|Function} key - the potentially nested keypath or property callback | ||
* @return {String} - the value at nested keypath | ||
*/ | ||
function getItemValue(item, key) { | ||
if (typeof key === 'function') { | ||
return key(item); | ||
} | ||
var isNested = key.indexOf('.') !== -1; | ||
@@ -247,0 +250,0 @@ if (!isNested) { |
@@ -402,6 +402,9 @@ var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {} | ||
* @param {Object} item - the item | ||
* @param {Object} key - the potentially nested keypath | ||
* @param {Object|Function} key - the potentially nested keypath or property callback | ||
* @return {String} - the value at nested keypath | ||
*/ | ||
function getItemValue(item, key) { | ||
if (typeof key === 'function') { | ||
return key(item); | ||
} | ||
var isNested = key.indexOf('.') !== -1; | ||
@@ -408,0 +411,0 @@ if (!isNested) { |
@@ -1,2 +0,2 @@ | ||
function interopDefault(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}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=getMatchRanking(t,r,s);return o>n&&(n=o,l=a),{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.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,f=a===o;return f?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$1.clean(e)),e.toLowerCase()}function getItemValue(e,t){var r=t.indexOf(".")!==-1;return r?t.split(".").reduce(function(e,t){return e[t]},e):e[t]}function getAllValuesToRank(e,t){return t.reduce(function(t,r){return t.concat(getItemValue(e,r))},[])}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},diacritics=createCommonjsModule(function(e){!function(t,r){"undefined"!=typeof e&&e.exports?e.exports=r():"function"==typeof define&&define.amd?define(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})}),diacritics$1=interopDefault(diacritics),globalObject=createCommonjsModule(function(module){!function(e){try{e("export default global")}catch(t){try{e("export default self")}catch(t){try{module.exports=commonjsGlobal}catch(t){try{self.global=self}catch(t){window.global=window}}}}}(eval)}),globalObject$1=interopDefault(globalObject),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},rankings={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$1.matchSorter=matchSorter; | ||
function interopDefault(e){return e&&"object"==typeof e&&"default"in e?e["default"]:e}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=getMatchRanking(t,r,s);return o>n&&(n=o,l=a),{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.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,f=a===o;return f?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$1.clean(e)),e.toLowerCase()}function getItemValue(e,t){if("function"==typeof t)return t(e);var r=t.indexOf(".")!==-1;return r?t.split(".").reduce(function(e,t){return e[t]},e):e[t]}function getAllValuesToRank(e,t){return t.reduce(function(t,r){return t.concat(getItemValue(e,r))},[])}var commonjsGlobal="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},diacritics=createCommonjsModule(function(e){!function(t,r){"undefined"!=typeof e&&e.exports?e.exports=r():"function"==typeof define&&define.amd?define(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})}),diacritics$1=interopDefault(diacritics),globalObject=createCommonjsModule(function(module){!function(e){try{e("export default global")}catch(t){try{e("export default self")}catch(t){try{module.exports=commonjsGlobal}catch(t){try{self.global=self}catch(t){window.global=window}}}}}(eval)}),globalObject$1=interopDefault(globalObject),_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},rankings={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$1.matchSorter=matchSorter; | ||
//# sourceMappingURL=match-sorter.min.js.map |
{ | ||
"name": "match-sorter", | ||
"version": "1.4.1", | ||
"version": "1.5.0", | ||
"description": "Simple, expected, and deterministic best-match sorting of an array in JavaScript", | ||
@@ -8,3 +8,5 @@ "main": "dist/cjs/index.js", | ||
"start": "package-scripts", | ||
"test": "package-scripts test" | ||
"test": "package-scripts test", | ||
"commitmsg": "opt --in commit-msg --exec \"validate-commit-msg\"", | ||
"precommit": "opt --in pre-commit --exec \"npm start validate\"" | ||
}, | ||
@@ -27,17 +29,15 @@ "files": [ | ||
"all-contributors-cli": "^3.0.0", | ||
"ava": "^0.16.0", | ||
"babel-cli": "^6.7.7", | ||
"babel-plugin-istanbul": "2.0.0", | ||
"babel-jest": "15.0.0", | ||
"babel-polyfill": "6.13.0", | ||
"babel-preset-es2015": "^6.6.0", | ||
"babel-preset-stage-2": "^6.5.0", | ||
"babel-register": "^6.7.2", | ||
"codecov": "^1.0.1", | ||
"commitizen": "^2.8.6", | ||
"cross-env": "^2.0.0", | ||
"cz-conventional-changelog": "^1.2.0", | ||
"eslint": "^3.1.1", | ||
"eslint-config-kentcdodds": "^10.0.1", | ||
"ghooks": "^1.3.2", | ||
"eslint-config-kentcdodds": "^10.1.0", | ||
"husky": "0.11.7", | ||
"jest-cli": "15.1.0", | ||
"nodemon": "1.10.2", | ||
"nyc": "8.1.0", | ||
"opt-cli": "^1.4.2", | ||
@@ -57,30 +57,18 @@ "p-s": "^2.3.0", | ||
"kentcdodds", | ||
"kentcdodds/ava" | ||
"kentcdodds/jest" | ||
] | ||
}, | ||
"nyc": { | ||
"all": true, | ||
"check-coverage": true, | ||
"branches": 100, | ||
"function": 100, | ||
"lines": 100, | ||
"statements": 100, | ||
"reporter": [ | ||
"text", | ||
"lcov" | ||
], | ||
"include": [ | ||
"src" | ||
], | ||
"sourceMap": false, | ||
"instrument": false, | ||
"require": [ | ||
"babel-register" | ||
] | ||
"jest": { | ||
"cacheDirectory": "./node_modules/.cache", | ||
"testEnvironment": "node", | ||
"coverageThreshold": { | ||
"global": { | ||
"branches": 100, | ||
"functions": 100, | ||
"lines": 100, | ||
"statements": 100 | ||
} | ||
} | ||
}, | ||
"config": { | ||
"ghooks": { | ||
"commit-msg": "opt --in commit-msg --exec \"validate-commit-msg\"", | ||
"pre-commit": "opt --in pre-commit --exec \"npm start validate\"" | ||
}, | ||
"commitizen": { | ||
@@ -87,0 +75,0 @@ "path": "node_modules/cz-conventional-changelog" |
@@ -12,3 +12,3 @@ # match-sorter | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-3-orange.svg?style=flat-square)](#contributors) | ||
[![All Contributors](https://img.shields.io/badge/all_contributors-4-orange.svg?style=flat-square)](#contributors) | ||
[![PRs Welcome][prs-badge]][prs] | ||
@@ -116,2 +116,15 @@ [![Donate][donate-badge]][donate] | ||
__Property Callbacks__: Alternatively, you may also pass in a callback function that resolves the value of the key(s) you wish to match on. This is especially useful when interfacing with libraries such as Immutable.js | ||
```javascript | ||
const list = [ | ||
{name: 'Janice'}, | ||
{name: 'Fred'}, | ||
{name: 'George'}, | ||
{name: 'Jen'}, | ||
] | ||
matchSorter(list, 'j', {keys: [(item) => item.name]}) | ||
// [{name: 'Janice'}, {name: 'Jen'}] | ||
``` | ||
### threshold: `number` | ||
@@ -185,4 +198,4 @@ | ||
<!-- 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/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) | | ||
| :---: | :---: | :---: | :---: | | ||
<!-- ALL-CONTRIBUTORS-LIST:END --> | ||
@@ -189,0 +202,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
96684
24
853
239