UNPKG

deburr

Version:

Utility that simplifies substring search by normalizing character set. Diacritic marks and supplementary letters are converted to nearest ASCII character sequence before search.

1 lines 3.24 kB
!function(e,t){for(var n in t)e[n]=t[n]}(exports,function(e){function t(r){if(n[r])return n[r].exports;var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(1);Object.defineProperty(t,"Deburr",{enumerable:!0,get:function(){return r.Deburr}})},function(e,t,n){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),u=t.DEBURR_DROP_RE=/[\u0300-\u036f\ufe20-\ufe23\ufeff]/g,o=t.DEBURR=n(2),s={};t.Deburr=function(){function e(t){if(r(this,e),this._chars=[],this._offsets=[],this._string="",t=String(t),t in s)return s[t];s[t]=this;for(var n=0,i=0;i<t.length;++i){var f=t.charAt(i);f=u.test(f)?"":o[f]||f,this._chars[i]=f,this._offsets[i]=n,n+=f.length}this._string=this._chars.join("")}return i(e,[{key:"toString",value:function(){return this._string}},{key:"lookup",value:function(t){var n=arguments.length<=1||void 0===arguments[1]?0:arguments[1],r=this._chars,i=this._offsets;if(null==t||0==r.length)return null;var u=new e(t);if(n>=r.length)return null;var o=this._string.indexOf(u._string,i[n]);if(0>o)return null;var s=i.indexOf(o);if(0>s)return null;for(var f=0,l=0;l<u._string.length;++f)l+=r[s+f].length;return l>u._string.length?null:{offset:s,length:f}}},{key:"lookupAll",value:function(e){for(var t=arguments.length<=1||void 0===arguments[1]?0:arguments[1],n=arguments.length<=2||void 0===arguments[2]?this._chars.length:arguments[2],r=[];n>0;){var i=this.lookup(e,t);if(!i)break;r.push(i),t=i.offset+i.length,0==i.length&&t++,n--}return r}}]),e}()},function(e,t){e.exports={"À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","Ç":"C","ç":"c","Ð":"D","ð":"d","È":"E","É":"E","Ê":"E","Ë":"E","è":"e","é":"e","ê":"e","ë":"e","Ì":"I","Í":"I","Î":"I","Ï":"I","ì":"i","í":"i","î":"i","ï":"i","Ñ":"N","ñ":"n","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","Ù":"U","Ú":"U","Û":"U","Ü":"U","ù":"u","ú":"u","û":"u","ü":"u","Ý":"Y","ý":"y","ÿ":"y","Æ":"Ae","æ":"ae","Þ":"Th","þ":"th","ß":"ss","ё":"е","‼":"!!",",":",",":":":",";":";","…":"...","@":"@","©":"c","®":"R","™":"TM"," ":" ","›":">","‹":"<","‘":"'","’":"'","‚":"'","'":"'","︐":"'","‛":"'","、":"'","︑":"'","‵":"'","‶":"'","‷":"'''","«":'"',"»":'"',"„":'"',"“":'"',"”":'"',"〝":'"',"〞":'"',"〟":'"',"〃":'"',""":'"',"⁃":"-","‑":"-","‒":"-","–":"-","—":"-","―":"-","﹘":"-","﹣":"-","-":"-","‐":"-","־":"-","¢":"c","£":"L","¥":"Y","₩":"W","₤":"L","€":"e","¢":"c","£":"L","¥":"Y","₩":"W","$":"$","¤":"o","゠":"=","×":"x","±":"+-","¼":"1/4","½":"1/2","¾":"3/4","⁄":"/","/":"/","\":"\\"}}]));