-
Notifications
You must be signed in to change notification settings - Fork 3
/
fuzzyfind.min.js
7 lines (7 loc) · 1.46 KB
/
fuzzyfind.min.js
1
2
3
4
5
6
7
/*!
* Fuzzyfind - https://github.com/amjith/fuzzyfind
* A matching algorithm for filtering and ranking a list based on partial user input.
* Copyright (C) 2016 Amjith Ramanujam
* @license MIT
*/
var fuzzyfind=function(r){function t(e){if(n[e])return n[e].exports;var a=n[e]={exports:{},id:e,loaded:!1};return r[e].call(a.exports,a,a.exports,t),a.loaded=!0,a.exports}var n={};return t.m=r,t.c=n,t.p="",t(0)}([function(r,t,n){var e=n(1),a=n(2);r.exports=function(r,t,n){if("string"!=typeof r||""===r)return t;n=n||{};var o=n.accessor||function(r){return r},u=void 0===n.precision?1:n.precision,f=[],s=a(r,u);return t.forEach(function(r){var t=o(r);s.find(function(n){var a=e(t)["for"](n);return a.found&&f.push({gram:n,length:a.end-a.start,start:a.start,searchableItem:t,item:r}),a.found})}),f.sort(function(r,t){return r.gram.length!==t.gram.length?t.gram.length-r.gram.length:r.length!==t.length?r.length-t.length:r.start!==t.start?r.start-t.start:r.searchableItem>t.searchableItem?1:r.searchableItem<t.searchableItem?-1:0}).map(function(r){return r.item})}},function(r,t){r.exports=function(r){r=r.toLowerCase();var t={"for":function(t){var n=0,e={found:!0};t=t.toLowerCase();for(var a=t.length,o=0;o<a;o++){if(n=r.indexOf(t[o],n),n===-1)return{found:!1};0==o&&(e.start=n)}return e.end=n+1,e}};return t}},function(r,t){r.exports=function(r,t){for(var n=r.length,e=Math.ceil(n*t)||1,a=[],o=n;o>=e;){for(var u=n-o,f=0;f<=u;f++){var s=r.substr(f,o);a.indexOf(s)===-1&&a.push(s)}o--}return a}}]);