@marketto/diacritic-remover
Advanced tools
Comparing version 1.0.0 to 1.0.1
organization=marketto-github | ||
projectKey=Marketto_diacritic-remover | ||
serverUrl=https://sonarcloud.io | ||
serverVersion=8.0.0.2898 | ||
serverVersion=8.0.0.2933 | ||
dashboardUrl=https://sonarcloud.io/dashboard?id=Marketto_diacritic-remover | ||
ceTaskId=AW6gKjXP_HQhkGhTpRFV | ||
ceTaskUrl=https://sonarcloud.io/api/ce/task?id=AW6gKjXP_HQhkGhTpRFV | ||
ceTaskId=AW6miNxExbJNIhOUFixy | ||
ceTaskUrl=https://sonarcloud.io/api/ce/task?id=AW6miNxExbJNIhOUFixy |
/** | ||
* @marketto/diacritic-remover 1.0.0 | ||
* @marketto/diacritic-remover 1.0.1 | ||
* Copyright (c) 2019, Marco Ricupero <marco.ricupero@gmail.com> | ||
@@ -10,2 +10,17 @@ * License: MIT | ||
*/ | ||
var DiacriticFilter=function(){"use strict";function e(e){return"string"==typeof e}class t{get(t,r,i){return e(r)&&1===r.length?this.diacriticTrap(t,r):Reflect.get(t,r,i)}has(t,r){return e(r)&&1===r.length||Reflect.has(t,r)}diacriticTrap(e,t){}}class r extends t{diacriticTrap(t,r){super.diacriticTrap(t,r);const i=t.isUpperCase(r),s=r.toLowerCase(),a=Object.keys(t.dictionary).find(r=>e(t.dictionary[r])&&t.dictionary[r].includes(s));return i&&a?a.toUpperCase():a||r}}class i extends t{diacriticTrap(e,t){super.diacriticTrap(e,t);const r=e.dictionary[t.toLowerCase()];return r?e.isUpperCase(t)?r.toUpperCase():r:t}}class s extends t{diacriticTrap(e,t){super.diacriticTrap(e,t);const r=e.dictionary[t.toLowerCase()];return r?r+r.toUpperCase():t}}class a extends t{diacriticTrap(e,t){super.diacriticTrap(e,t);const r=e.dictionary[t.toLowerCase()];let i="";return r&&(i=e.isUpperCase(t)?r.toUpperCase():r),new RegExp(`[${t}${i}]`,"u")}}class c extends t{diacriticTrap(e,t){return super.diacriticTrap(e,t),new RegExp(`[${t}${e.insensitiveMatcher[t]||""}]`,"ui")}}class n{constructor(t){const r=t.reduce((t,r)=>(Object.entries(r).forEach(([r,i])=>{if(e(i))if(r in t){const e=i.split("").filter(e=>!t[r].includes(e)).join("");t[r]+=e}else t[r]=i}),t),{});this.dictionary=Object.freeze(r),this.matcher=new Proxy(this,new i),this.insensitiveMatcher=new Proxy(this,new s),this.validator=new Proxy(this,new a),this.insensitiveValidator=new Proxy(this,new c)}matcherBy(e){return[...Object.keys(this.dictionary).filter(t=>e.test(t)).map(e=>this.dictionary[e]),...Object.keys(this.dictionary).filter(t=>e.test(t.toUpperCase())).map(e=>this.dictionary[e.toUpperCase()].toUpperCase())].join("")}replace(e){return e.replace(/./g,e=>this[e])}isUpperCase(e=""){return e.toUpperCase()===e}isLowerCase(e=""){return e.toLowerCase()===e}}var o={a:"áäâàåÄąāãă",e:"éèêëěÊęėēё",i:"íîïi̇řìįī",o:"óôöòøōõơ",u:"úûüùůŭųūư",y:"ýÿŷỳ",n:"ñňŋņń",l:"ḷŀłļĺľ",h:"ḥĥȟħ",c:"çčćĉĊ",g:"ğĝǧģĠġ",s:"şšŝṣșſś","у":"ў","и":"йѝ","е":"ё",d:"đďðḏ",z:"žŻźż",t:"ťțțṭ",w:"ẅŵẃẁ",ae:"æ",ss:"ß","α":"ά","ε":"έ","η":"ή","ι":"ίΐϊ","ο":"ό","υ":"ύΰϋ","ω":"ώ",j:"ĵ",oe:"œ","":"ʰ'ʼ·׳",ii:"î",k:"ķ","к":"ќ","г":"ѓґ",ij:"ij",r:"ŕ","і":"ї"};return class extends n{constructor(...e){return super(e.length?e:[o]),Object.defineProperty(this,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(this,new r)}}}(); | ||
var DiacriticFilter=function(){"use strict"; | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */var t=function(r,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(r,n)};function r(r,n){function i(){this.constructor=r}t(r,n),r.prototype=null===n?Object.create(n):(i.prototype=n.prototype,new i)}function n(t){return"string"==typeof t}var i=function(){function t(){}return t.prototype.get=function(t,r,i){return n(r)&&1===r.length?this.diacriticTrap(t,r):Reflect.get(t,r,i)},t.prototype.has=function(t,r){return n(r)&&1===r.length||Reflect.has(t,r)},t.prototype.diacriticTrap=function(t,r){},t}(),e=function(t){function i(){return null!==t&&t.apply(this,arguments)||this}return r(i,t),i.prototype.diacriticTrap=function(r,i){t.prototype.diacriticTrap.call(this,r,i);var e=r.isUpperCase(i),o=i.toLowerCase(),c=Object.keys(r.dictionary).find((function(t){return n(r.dictionary[t])&&r.dictionary[t].includes(o)}));return e&&c?c.toUpperCase():c||i},i}(i),o=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){t.prototype.diacriticTrap.call(this,r,n);var i=r.dictionary[n.toLowerCase()];return i?r.isUpperCase(n)?i.toUpperCase():i:n},n}(i),c=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){t.prototype.diacriticTrap.call(this,r,n);var i=r.dictionary[n.toLowerCase()];return i?i+i.toUpperCase():n},n}(i),a=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){t.prototype.diacriticTrap.call(this,r,n);var i=r.dictionary[n.toLowerCase()],e="";return i&&(e=r.isUpperCase(n)?i.toUpperCase():i),new RegExp("["+n+e+"]","u")},n}(i),u=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){return t.prototype.diacriticTrap.call(this,r,n),new RegExp("["+n+(r.insensitiveMatcher[n]||"")+"]","ui")},n}(i),p=function(){function t(t){var r=t.reduce((function(t,r){return Object.entries(r).forEach((function(r){var i=r[0],e=r[1];if(n(e))if(i in t){var o=e.split("").filter((function(r){return!t[i].includes(r)})).join("");t[i]+=o}else t[i]=e})),t}),{});this.dictionary=Object.freeze(r),this.matcher=new Proxy(this,new o),this.insensitiveMatcher=new Proxy(this,new c),this.validator=new Proxy(this,new a),this.insensitiveValidator=new Proxy(this,new u)}return t.prototype.matcherBy=function(t){var r=this;return function(){for(var t=0,r=0,n=arguments.length;r<n;r++)t+=arguments[r].length;var i=Array(t),e=0;for(r=0;r<n;r++)for(var o=arguments[r],c=0,a=o.length;c<a;c++,e++)i[e]=o[c];return i}(Object.keys(this.dictionary).filter((function(r){return t.test(r)})).map((function(t){return r.dictionary[t]})),Object.keys(this.dictionary).filter((function(r){return t.test(r.toUpperCase())})).map((function(t){return r.dictionary[t.toLowerCase()].toUpperCase()}))).join("")},t.prototype.replace=function(t){var r=this;return t.replace(/./g,(function(t){return r[t]}))},t.prototype.isUpperCase=function(t){return void 0===t&&(t=""),t.toUpperCase()===t},t.prototype.isLowerCase=function(t){return void 0===t&&(t=""),t.toLowerCase()===t},t}(),s={a:"áäâàåÄąāãă",e:"éèêëěÊęėēё",i:"íîïi̇řìįī",o:"óôöòøōõơ",u:"úûüùůŭųūư",y:"ýÿŷỳ",n:"ñňŋņń",l:"ḷŀłļĺľ",h:"ḥĥȟħ",c:"çčćĉĊ",g:"ğĝǧģĠġ",s:"şšŝṣșſś","у":"ў","и":"йѝ","е":"ё",d:"đďðḏ",z:"žŻźż",t:"ťțțṭ",w:"ẅŵẃẁ",ae:"æ",ss:"ß","α":"ά","ε":"έ","η":"ή","ι":"ίΐϊ","ο":"ό","υ":"ύΰϋ","ω":"ώ",j:"ĵ",oe:"œ","":"ʰ'ʼ·׳",ii:"î",k:"ķ","к":"ќ","г":"ѓґ",ij:"ij",r:"ŕ","і":"ї"};return function(t){function n(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var i=t.call(this,r.length?r:[s])||this;return Object.defineProperty(i,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(i,new e)}return r(n,t),n}(p)}(); | ||
//# sourceMappingURL=diacritic-remover.bundle.js.map |
/** | ||
* @marketto/diacritic-remover 1.0.0 | ||
* @marketto/diacritic-remover 1.0.1 | ||
* Copyright (c) 2019, Marco Ricupero <marco.ricupero@gmail.com> | ||
@@ -10,2 +10,17 @@ * License: MIT | ||
*/ | ||
function e(e){return"string"==typeof e}class t{get(t,r,i){return e(r)&&1===r.length?this.diacriticTrap(t,r):Reflect.get(t,r,i)}has(t,r){return e(r)&&1===r.length||Reflect.has(t,r)}diacriticTrap(e,t){}}class r extends t{diacriticTrap(t,r){super.diacriticTrap(t,r);const i=t.isUpperCase(r),s=r.toLowerCase(),a=Object.keys(t.dictionary).find(r=>e(t.dictionary[r])&&t.dictionary[r].includes(s));return i&&a?a.toUpperCase():a||r}}class i extends t{diacriticTrap(e,t){super.diacriticTrap(e,t);const r=e.dictionary[t.toLowerCase()];return r?e.isUpperCase(t)?r.toUpperCase():r:t}}class s extends t{diacriticTrap(e,t){super.diacriticTrap(e,t);const r=e.dictionary[t.toLowerCase()];return r?r+r.toUpperCase():t}}class a extends t{diacriticTrap(e,t){super.diacriticTrap(e,t);const r=e.dictionary[t.toLowerCase()];let i="";return r&&(i=e.isUpperCase(t)?r.toUpperCase():r),new RegExp(`[${t}${i}]`,"u")}}class c extends t{diacriticTrap(e,t){return super.diacriticTrap(e,t),new RegExp(`[${t}${e.insensitiveMatcher[t]||""}]`,"ui")}}class n{constructor(t){const r=t.reduce((t,r)=>(Object.entries(r).forEach(([r,i])=>{if(e(i))if(r in t){const e=i.split("").filter(e=>!t[r].includes(e)).join("");t[r]+=e}else t[r]=i}),t),{});this.dictionary=Object.freeze(r),this.matcher=new Proxy(this,new i),this.insensitiveMatcher=new Proxy(this,new s),this.validator=new Proxy(this,new a),this.insensitiveValidator=new Proxy(this,new c)}matcherBy(e){return[...Object.keys(this.dictionary).filter(t=>e.test(t)).map(e=>this.dictionary[e]),...Object.keys(this.dictionary).filter(t=>e.test(t.toUpperCase())).map(e=>this.dictionary[e.toUpperCase()].toUpperCase())].join("")}replace(e){return e.replace(/./g,e=>this[e])}isUpperCase(e=""){return e.toUpperCase()===e}isLowerCase(e=""){return e.toLowerCase()===e}}var o={a:"áäâàåÄąāãă",e:"éèêëěÊęėēё",i:"íîïi̇řìįī",o:"óôöòøōõơ",u:"úûüùůŭųūư",y:"ýÿŷỳ",n:"ñňŋņń",l:"ḷŀłļĺľ",h:"ḥĥȟħ",c:"çčćĉĊ",g:"ğĝǧģĠġ",s:"şšŝṣșſś","у":"ў","и":"йѝ","е":"ё",d:"đďðḏ",z:"žŻźż",t:"ťțțṭ",w:"ẅŵẃẁ",ae:"æ",ss:"ß","α":"ά","ε":"έ","η":"ή","ι":"ίΐϊ","ο":"ό","υ":"ύΰϋ","ω":"ώ",j:"ĵ",oe:"œ","":"ʰ'ʼ·׳",ii:"î",k:"ķ","к":"ќ","г":"ѓґ",ij:"ij",r:"ŕ","і":"ї"};export default class extends n{constructor(...e){return super(e.length?e:[o]),Object.defineProperty(this,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(this,new r)}} | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
***************************************************************************** */ | ||
var t=function(r,n){return(t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,r){t.__proto__=r}||function(t,r){for(var n in r)r.hasOwnProperty(n)&&(t[n]=r[n])})(r,n)};function r(r,n){function e(){this.constructor=r}t(r,n),r.prototype=null===n?Object.create(n):(e.prototype=n.prototype,new e)}function n(t){return"string"==typeof t}var e=function(){function t(){}return t.prototype.get=function(t,r,e){return n(r)&&1===r.length?this.diacriticTrap(t,r):Reflect.get(t,r,e)},t.prototype.has=function(t,r){return n(r)&&1===r.length||Reflect.has(t,r)},t.prototype.diacriticTrap=function(t,r){},t}(),i=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e.prototype.diacriticTrap=function(r,e){t.prototype.diacriticTrap.call(this,r,e);var i=r.isUpperCase(e),o=e.toLowerCase(),c=Object.keys(r.dictionary).find((function(t){return n(r.dictionary[t])&&r.dictionary[t].includes(o)}));return i&&c?c.toUpperCase():c||e},e}(e),o=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){t.prototype.diacriticTrap.call(this,r,n);var e=r.dictionary[n.toLowerCase()];return e?r.isUpperCase(n)?e.toUpperCase():e:n},n}(e),c=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){t.prototype.diacriticTrap.call(this,r,n);var e=r.dictionary[n.toLowerCase()];return e?e+e.toUpperCase():n},n}(e),a=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){t.prototype.diacriticTrap.call(this,r,n);var e=r.dictionary[n.toLowerCase()],i="";return e&&(i=r.isUpperCase(n)?e.toUpperCase():e),new RegExp("["+n+i+"]","u")},n}(e),p=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return r(n,t),n.prototype.diacriticTrap=function(r,n){return t.prototype.diacriticTrap.call(this,r,n),new RegExp("["+n+(r.insensitiveMatcher[n]||"")+"]","ui")},n}(e),u=function(){function t(t){var r=t.reduce((function(t,r){return Object.entries(r).forEach((function(r){var e=r[0],i=r[1];if(n(i))if(e in t){var o=i.split("").filter((function(r){return!t[e].includes(r)})).join("");t[e]+=o}else t[e]=i})),t}),{});this.dictionary=Object.freeze(r),this.matcher=new Proxy(this,new o),this.insensitiveMatcher=new Proxy(this,new c),this.validator=new Proxy(this,new a),this.insensitiveValidator=new Proxy(this,new p)}return t.prototype.matcherBy=function(t){var r=this;return function(){for(var t=0,r=0,n=arguments.length;r<n;r++)t+=arguments[r].length;var e=Array(t),i=0;for(r=0;r<n;r++)for(var o=arguments[r],c=0,a=o.length;c<a;c++,i++)e[i]=o[c];return e}(Object.keys(this.dictionary).filter((function(r){return t.test(r)})).map((function(t){return r.dictionary[t]})),Object.keys(this.dictionary).filter((function(r){return t.test(r.toUpperCase())})).map((function(t){return r.dictionary[t.toLowerCase()].toUpperCase()}))).join("")},t.prototype.replace=function(t){var r=this;return t.replace(/./g,(function(t){return r[t]}))},t.prototype.isUpperCase=function(t){return void 0===t&&(t=""),t.toUpperCase()===t},t.prototype.isLowerCase=function(t){return void 0===t&&(t=""),t.toLowerCase()===t},t}(),s={a:"áäâàåÄąāãă",e:"éèêëěÊęėēё",i:"íîïi̇řìįī",o:"óôöòøōõơ",u:"úûüùůŭųūư",y:"ýÿŷỳ",n:"ñňŋņń",l:"ḷŀłļĺľ",h:"ḥĥȟħ",c:"çčćĉĊ",g:"ğĝǧģĠġ",s:"şšŝṣșſś","у":"ў","и":"йѝ","е":"ё",d:"đďðḏ",z:"žŻźż",t:"ťțțṭ",w:"ẅŵẃẁ",ae:"æ",ss:"ß","α":"ά","ε":"έ","η":"ή","ι":"ίΐϊ","ο":"ό","υ":"ύΰϋ","ω":"ώ",j:"ĵ",oe:"œ","":"ʰ'ʼ·׳",ii:"î",k:"ķ","к":"ќ","г":"ѓґ",ij:"ij",r:"ŕ","і":"ї"},f=function(t){function n(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var e=t.call(this,r.length?r:[s])||this;return Object.defineProperty(e,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(e,new i)}return r(n,t),n}(u);export default f; | ||
//# sourceMappingURL=diacritic-remover.es.js.map |
/** | ||
* @marketto/diacritic-remover 1.0.0 | ||
* @marketto/diacritic-remover 1.0.1 | ||
* Copyright (c) 2019, Marco Ricupero <marco.ricupero@gmail.com> | ||
@@ -10,2 +10,3 @@ * License: MIT | ||
*/ | ||
"use strict";function isString(i){return"string"==typeof i}class DiacriticAbstractHandler{get(i,e,r){return isString(e)&&1===e.length?this.diacriticTrap(i,e):Reflect.get(i,e,r)}has(i,e){return isString(e)&&1===e.length||Reflect.has(i,e)}diacriticTrap(i,e){}}class DiacriticRemoverHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.isUpperCase(e),t=e.toLowerCase(),a=Object.keys(i.dictionary).find(e=>isString(i.dictionary[e])&&i.dictionary[e].includes(t));return r&&a?a.toUpperCase():a||e}}class DiacriticMatcherHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.dictionary[e.toLowerCase()];return r?i.isUpperCase(e)?r.toUpperCase():r:e}}class DiacriticInsensitiveMatcherHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.dictionary[e.toLowerCase()];return r?r+r.toUpperCase():e}}class DiacriticValidatorHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.dictionary[e.toLowerCase()];let t="";return r&&(t=i.isUpperCase(e)?r.toUpperCase():r),new RegExp(`[${e}${t}]`,"u")}}class DiacriticInsensitiveValidatorHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){return super.diacriticTrap(i,e),new RegExp(`[${e}${i.insensitiveMatcher[e]||""}]`,"ui")}}class DiacriticMapperCore{constructor(i){const e=i.reduce((i,e)=>(Object.entries(e).forEach(([e,r])=>{if(isString(r))if(e in i){const t=r.split("").filter(r=>!i[e].includes(r)).join("");i[e]+=t}else i[e]=r}),i),{});this.dictionary=Object.freeze(e),this.matcher=new Proxy(this,new DiacriticMatcherHandler),this.insensitiveMatcher=new Proxy(this,new DiacriticInsensitiveMatcherHandler),this.validator=new Proxy(this,new DiacriticValidatorHandler),this.insensitiveValidator=new Proxy(this,new DiacriticInsensitiveValidatorHandler)}matcherBy(i){return[...Object.keys(this.dictionary).filter(e=>i.test(e)).map(i=>this.dictionary[i]),...Object.keys(this.dictionary).filter(e=>i.test(e.toUpperCase())).map(i=>this.dictionary[i.toUpperCase()].toUpperCase())].join("")}replace(i){return i.replace(/./g,i=>this[i])}isUpperCase(i=""){return i.toUpperCase()===i}isLowerCase(i=""){return i.toLowerCase()===i}}var I18N_ALL={a:"áäâàåÄąāãă",e:"éèêëěÊęėēё",i:"íîïi̇řìįī",o:"óôöòøōõơ",u:"úûüùůŭųūư",y:"ýÿŷỳ",n:"ñňŋņń",l:"ḷŀłļĺľ",h:"ḥĥȟħ",c:"çčćĉĊ",g:"ğĝǧģĠġ",s:"şšŝṣșſś","у":"ў","и":"йѝ","е":"ё",d:"đďðḏ",z:"žŻźż",t:"ťțțṭ",w:"ẅŵẃẁ",ae:"æ",ss:"ß","α":"ά","ε":"έ","η":"ή","ι":"ίΐϊ","ο":"ό","υ":"ύΰϋ","ω":"ώ",j:"ĵ",oe:"œ","":"ʰ'ʼ·׳",ii:"î",k:"ķ","к":"ќ","г":"ѓґ",ij:"ij",r:"ŕ","і":"ї"};class DiacriticRemover extends DiacriticMapperCore{constructor(...i){return super(i.length?i:[I18N_ALL]),Object.defineProperty(this,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(this,new DiacriticRemoverHandler)}}module.exports=DiacriticRemover; | ||
"use strict";function isString(i){return"string"==typeof i}class DiacriticAbstractHandler{get(i,e,r){return isString(e)&&1===e.length?this.diacriticTrap(i,e):Reflect.get(i,e,r)}has(i,e){return isString(e)&&1===e.length||Reflect.has(i,e)}diacriticTrap(i,e){}}class DiacriticRemoverHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.isUpperCase(e),t=e.toLowerCase(),a=Object.keys(i.dictionary).find(e=>isString(i.dictionary[e])&&i.dictionary[e].includes(t));return r&&a?a.toUpperCase():a||e}}class DiacriticMatcherHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.dictionary[e.toLowerCase()];return r?i.isUpperCase(e)?r.toUpperCase():r:e}}class DiacriticInsensitiveMatcherHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.dictionary[e.toLowerCase()];return r?r+r.toUpperCase():e}}class DiacriticValidatorHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){super.diacriticTrap(i,e);const r=i.dictionary[e.toLowerCase()];let t="";return r&&(t=i.isUpperCase(e)?r.toUpperCase():r),new RegExp(`[${e}${t}]`,"u")}}class DiacriticInsensitiveValidatorHandler extends DiacriticAbstractHandler{diacriticTrap(i,e){return super.diacriticTrap(i,e),new RegExp(`[${e}${i.insensitiveMatcher[e]||""}]`,"ui")}}class DiacriticMapperCore{constructor(i){const e=i.reduce((i,e)=>(Object.entries(e).forEach(([e,r])=>{if(isString(r))if(e in i){const t=r.split("").filter(r=>!i[e].includes(r)).join("");i[e]+=t}else i[e]=r}),i),{});this.dictionary=Object.freeze(e),this.matcher=new Proxy(this,new DiacriticMatcherHandler),this.insensitiveMatcher=new Proxy(this,new DiacriticInsensitiveMatcherHandler),this.validator=new Proxy(this,new DiacriticValidatorHandler),this.insensitiveValidator=new Proxy(this,new DiacriticInsensitiveValidatorHandler)}matcherBy(i){return[...Object.keys(this.dictionary).filter(e=>i.test(e)).map(i=>this.dictionary[i]),...Object.keys(this.dictionary).filter(e=>i.test(e.toUpperCase())).map(i=>this.dictionary[i.toLowerCase()].toUpperCase())].join("")}replace(i){return i.replace(/./g,i=>this[i])}isUpperCase(i=""){return i.toUpperCase()===i}isLowerCase(i=""){return i.toLowerCase()===i}}var I18N_ALL={a:"áäâàåÄąāãă",e:"éèêëěÊęėēё",i:"íîïi̇řìįī",o:"óôöòøōõơ",u:"úûüùůŭųūư",y:"ýÿŷỳ",n:"ñňŋņń",l:"ḷŀłļĺľ",h:"ḥĥȟħ",c:"çčćĉĊ",g:"ğĝǧģĠġ",s:"şšŝṣșſś","у":"ў","и":"йѝ","е":"ё",d:"đďðḏ",z:"žŻźż",t:"ťțțṭ",w:"ẅŵẃẁ",ae:"æ",ss:"ß","α":"ά","ε":"έ","η":"ή","ι":"ίΐϊ","ο":"ό","υ":"ύΰϋ","ω":"ώ",j:"ĵ",oe:"œ","":"ʰ'ʼ·׳",ii:"î",k:"ķ","к":"ќ","г":"ѓґ",ij:"ij",r:"ŕ","і":"ї"};class DiacriticRemover extends DiacriticMapperCore{constructor(...i){return super(i.length?i:[I18N_ALL]),Object.defineProperty(this,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(this,new DiacriticRemoverHandler)}}module.exports=DiacriticRemover; | ||
//# sourceMappingURL=diacritic-remover.js.map |
{ | ||
"name": "@marketto/diacritic-remover", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tool to replace diacritics in strings", | ||
@@ -8,2 +8,17 @@ "main": "dist/diacritic-remover.js", | ||
"browser": "dist/diacritic-remover.bundle.js", | ||
"types": "dist/diacritic-remover.d.ts", | ||
"bugs": { | ||
"url": "https://github.com/Marketto/diacritic-remover/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/Marketto/diacritic-remover.git" | ||
}, | ||
"keywords": [ | ||
"diacritic", | ||
"remover", | ||
"replace", | ||
"accent", | ||
"typescript" | ||
], | ||
"dependencies": {}, | ||
@@ -15,2 +30,3 @@ "devDependencies": { | ||
"@types/node": "^12.12.7", | ||
"@wessberg/rollup-plugin-ts": "^1.1.80", | ||
"chai": "^4.2.0", | ||
@@ -27,3 +43,2 @@ "cross-env": "^6.0.3", | ||
"rollup-plugin-terser": "^5.1.2", | ||
"rollup-plugin-typescript2": "^0.24.3", | ||
"ts-node": "^8.4.1", | ||
@@ -30,0 +45,0 @@ "tslint": "^6.0.0-beta0", |
@@ -1,3 +0,2 @@ | ||
import rollupTypescript from 'rollup-plugin-typescript2'; | ||
import typescript from 'typescript'; | ||
import rollupPluginTs from "@wessberg/rollup-plugin-ts"; | ||
import pkg from './package.json'; | ||
@@ -9,19 +8,4 @@ import { terser } from 'rollup-plugin-terser'; | ||
export default { | ||
const baseConf = { | ||
input: 'src/diacritic-remover.ts', | ||
output: [ | ||
{ | ||
file: pkg.main, | ||
format: 'cjs' | ||
}, | ||
{ | ||
file: pkg.module, | ||
format: 'es' | ||
}, | ||
{ | ||
file: pkg.browser, | ||
format: 'iife', | ||
name: 'DiacriticFilter' | ||
} | ||
], | ||
external: [ | ||
@@ -32,3 +16,3 @@ ...Object.keys(pkg.dependencies || {}), | ||
plugins: [ | ||
rollupTypescript({ typescript, tsconfig: './src/tsconfig.json' }), | ||
//rollupPluginTs({}), | ||
builtins(), | ||
@@ -45,2 +29,43 @@ terser(), | ||
], | ||
}; | ||
} | ||
export default [ | ||
{ | ||
...baseConf, | ||
output: [ | ||
{ | ||
file: pkg.main, | ||
format: 'cjs', | ||
sourcemap: true | ||
} | ||
], | ||
plugins: [ | ||
rollupPluginTs({}), | ||
...baseConf.plugins | ||
] | ||
}, | ||
{ | ||
...baseConf, | ||
output: [ | ||
{ | ||
file: pkg.module, | ||
format: 'es', | ||
sourcemap: true | ||
}, | ||
{ | ||
file: pkg.browser, | ||
format: 'iife', | ||
name: 'DiacriticFilter', | ||
sourcemap: true | ||
} | ||
], | ||
plugins: [ | ||
rollupPluginTs({ | ||
tsconfig: { | ||
declaration: false | ||
} | ||
}), | ||
...baseConf.plugins | ||
] | ||
} | ||
]; |
@@ -52,3 +52,3 @@ import DiacriticSetInterface from '../interfaces/diacritic-set.interface'; | ||
.filter(key => regexp.test(key.toUpperCase())) | ||
.map(key => this.dictionary[key.toUpperCase()].toUpperCase()); | ||
.map(key => this.dictionary[key.toLowerCase()].toUpperCase()); | ||
@@ -55,0 +55,0 @@ return [...lowerCase, ...upperCase].join(''); |
@@ -11,6 +11,6 @@ { | ||
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */ | ||
// "declaration": true, /* Generates corresponding '.d.ts' file. */ | ||
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ | ||
"declaration": true, /* Generates corresponding '.d.ts' file. */ | ||
//"declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */ | ||
// "sourceMap": true, /* Generates corresponding '.map' file. */ | ||
// "outFile": "./", /* Concatenate and emit output to single file. */ | ||
// "outFile": "./dist/test", /* Concatenate and emit output to single file. */ | ||
// "outDir": "./", /* Redirect output structure to the directory. */ | ||
@@ -17,0 +17,0 @@ // "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
182088
34
584
0
0
0