Socket
Socket
Sign inDemoInstall

@marketto/diacritic-remover

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 1.0.3

CHANGELOG.md

18

dist/diacritic-remover.bundle.js
/**
* @marketto/diacritic-remover 1.0.2
* @marketto/diacritic-remover 1.0.3
* Copyright (c) 2019, Marco Ricupero <marco.ricupero@gmail.com>

@@ -10,17 +10,3 @@ * License: MIT

*/
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 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),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}(e),p=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 u)}return t.prototype.matcherBy=function(t){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.entries(this.dictionary).filter((function(r){var n=r[0];return r[1]&&t.test(n)})).map((function(t){return t[1]})),Object.entries(this.dictionary).filter((function(r){var n=r[0];return r[1]&&t.test(n.toUpperCase())})).map((function(t){return t[1].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 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}(p)}();
var DiacriticFilter=function(){"use strict";function e(e){return"string"==typeof e}class t{get(t,r,i){return e(r)&&r.length<=1?this.diacriticTrap(t,r):Reflect.get(t,r,i)}diacriticTrap(e,t){return t}}class r extends t{diacriticTrap(t,r){super.diacriticTrap(t,r);const i=t.isUpperCase(r),s=r.toLowerCase(),[a]=Object.entries(t.dictionary).find(([,t])=>e(t)&&t.includes(s))||[];return i&&a?a.toUpperCase():e(a)?a:r}}class i extends t{diacriticTrap(e,t){let r=super.diacriticTrap(e,t);const i=e.dictionary[t.toLowerCase()];return i&&(r+=e.isUpperCase(r)?i.toUpperCase():i),r}}class s extends t{diacriticTrap(e,t){const r=super.diacriticTrap(e,t).toLowerCase(),i=new Set([r,r.toUpperCase()]);return[...e.dictionary[r]||""].forEach(e=>{i.add(e),i.add(e.toUpperCase())}),[...i].sort().join("")}}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 n extends t{diacriticTrap(e,t){return super.diacriticTrap(e,t),new RegExp(`[${t}${e.insensitiveMatcher[t]||""}]`,"ui")}}class c{constructor(e){const t=e.reduce((e,t)=>Object.entries(t).reduce((e,[t,r])=>Object.assign(Object.assign({},e),{[t]:(e[t]||"")+r}),e),{});Object.entries(t).forEach(([e,r])=>{t[e]=[...new Set([...r])].sort().join("")}),this.dictionary=Object.freeze(t),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 n)}matcherBy(e){return[...Object.entries(this.dictionary).filter(([t,r])=>r&&e.test(t)).map(([e,t])=>e+t),...Object.entries(this.dictionary).filter(([t,r])=>r&&e.test(t.toUpperCase())).map(([e,t])=>(e+t).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 c{constructor(...e){return super(e.length?e:[o]),Object.defineProperty(this,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(this,new r)}}}();
//# sourceMappingURL=diacritic-remover.bundle.js.map
/**
* @marketto/diacritic-remover 1.0.2
* @marketto/diacritic-remover 1.0.3
* Copyright (c) 2019, Marco Ricupero <marco.ricupero@gmail.com>

@@ -10,17 +10,3 @@ * License: MIT

*/
/*! *****************************************************************************
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){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.entries(this.dictionary).filter((function(r){var n=r[0];return r[1]&&t.test(n)})).map((function(t){return t[1]})),Object.entries(this.dictionary).filter((function(r){var n=r[0];return r[1]&&t.test(n.toUpperCase())})).map((function(t){return t[1].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;
function e(e){return"string"==typeof e}class t{get(t,r,i){return e(r)&&r.length<=1?this.diacriticTrap(t,r):Reflect.get(t,r,i)}diacriticTrap(e,t){return t}}class r extends t{diacriticTrap(t,r){super.diacriticTrap(t,r);const i=t.isUpperCase(r),s=r.toLowerCase(),[a]=Object.entries(t.dictionary).find(([,t])=>e(t)&&t.includes(s))||[];return i&&a?a.toUpperCase():e(a)?a:r}}class i extends t{diacriticTrap(e,t){let r=super.diacriticTrap(e,t);const i=e.dictionary[t.toLowerCase()];return i&&(r+=e.isUpperCase(r)?i.toUpperCase():i),r}}class s extends t{diacriticTrap(e,t){const r=super.diacriticTrap(e,t).toLowerCase(),i=new Set([r,r.toUpperCase()]);return[...e.dictionary[r]||""].forEach(e=>{i.add(e),i.add(e.toUpperCase())}),[...i].sort().join("")}}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 n extends t{diacriticTrap(e,t){return super.diacriticTrap(e,t),new RegExp(`[${t}${e.insensitiveMatcher[t]||""}]`,"ui")}}class c{constructor(e){const t=e.reduce((e,t)=>Object.entries(t).reduce((e,[t,r])=>Object.assign(Object.assign({},e),{[t]:(e[t]||"")+r}),e),{});Object.entries(t).forEach(([e,r])=>{t[e]=[...new Set([...r])].sort().join("")}),this.dictionary=Object.freeze(t),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 n)}matcherBy(e){return[...Object.entries(this.dictionary).filter(([t,r])=>r&&e.test(t)).map(([e,t])=>e+t),...Object.entries(this.dictionary).filter(([t,r])=>r&&e.test(t.toUpperCase())).map(([e,t])=>(e+t).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 c{constructor(...e){return super(e.length?e:[o]),Object.defineProperty(this,"dictionary",{enumerable:!1,configurable:!1}),new Proxy(this,new r)}}
//# sourceMappingURL=diacritic-remover.es.js.map
/**
* @marketto/diacritic-remover 1.0.2
* @marketto/diacritic-remover 1.0.3
* Copyright (c) 2019, Marco Ricupero <marco.ricupero@gmail.com>

@@ -10,3 +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.entries(this.dictionary).filter(([e,r])=>r&&i.test(e)).map(([,i])=>i),...Object.entries(this.dictionary).filter(([e,r])=>r&&i.test(e.toUpperCase())).map(([,i])=>i.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(e){return"string"==typeof e}class DiacriticAbstractHandler{get(e,i,r){return isString(i)&&i.length<=1?this.diacriticTrap(e,i):Reflect.get(e,i,r)}diacriticTrap(e,i){return i}}class DiacriticRemoverHandler extends DiacriticAbstractHandler{diacriticTrap(e,i){super.diacriticTrap(e,i);const r=e.isUpperCase(i),t=i.toLowerCase(),[a]=Object.entries(e.dictionary).find(([,e])=>isString(e)&&e.includes(t))||[];return r&&a?a.toUpperCase():isString(a)?a:i}}class DiacriticMatcherHandler extends DiacriticAbstractHandler{diacriticTrap(e,i){let r=super.diacriticTrap(e,i);const t=e.dictionary[i.toLowerCase()];return t&&(r+=e.isUpperCase(r)?t.toUpperCase():t),r}}class DiacriticInsensitiveMatcherHandler extends DiacriticAbstractHandler{diacriticTrap(e,i){const r=super.diacriticTrap(e,i).toLowerCase(),t=new Set([r,r.toUpperCase()]);return[...e.dictionary[r]||""].forEach(e=>{t.add(e),t.add(e.toUpperCase())}),[...t].sort().join("")}}class DiacriticValidatorHandler extends DiacriticAbstractHandler{diacriticTrap(e,i){super.diacriticTrap(e,i);const r=e.dictionary[i.toLowerCase()];let t="";return r&&(t=e.isUpperCase(i)?r.toUpperCase():r),new RegExp(`[${i}${t}]`,"u")}}class DiacriticInsensitiveValidatorHandler extends DiacriticAbstractHandler{diacriticTrap(e,i){return super.diacriticTrap(e,i),new RegExp(`[${i}${e.insensitiveMatcher[i]||""}]`,"ui")}}class DiacriticMapperCore{constructor(e){const i=e.reduce((e,i)=>Object.entries(i).reduce((e,[i,r])=>Object.assign(Object.assign({},e),{[i]:(e[i]||"")+r}),e),{});Object.entries(i).forEach(([e,r])=>{i[e]=[...new Set([...r])].sort().join("")}),this.dictionary=Object.freeze(i),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(e){return[...Object.entries(this.dictionary).filter(([i,r])=>r&&e.test(i)).map(([e,i])=>e+i),...Object.entries(this.dictionary).filter(([i,r])=>r&&e.test(i.toUpperCase())).map(([e,i])=>(e+i).toUpperCase())].join("")}replace(e){return e.replace(/./g,e=>this[e])}isUpperCase(e=""){return e.toUpperCase()===e}isLowerCase(e=""){return e.toLowerCase()===e}}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(...e){return super(e.length?e:[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.2",
"version": "1.0.3",
"description": "Tool to replace diacritics in strings",

@@ -46,2 +46,3 @@ "main": "dist/diacritic-remover.js",

"scripts": {
"release": "npm audit fix && npm run lint-fix && npm run test && npm run build",
"build": "node ./scripts/i18n-all.js && npx rollup -c",

@@ -48,0 +49,0 @@ "lint": "npx tslint -c tslint.json \"src/**/*.ts\"",

@@ -18,2 +18,4 @@ # diacritic-remover

## [CHANGELOG](CHANGELOG.md)
## INSTALLATION

@@ -101,12 +103,2 @@ ```{r, engine='bash', global_install}

## CHANGELOG
### 1.0.2
* matcherBy Refactoring
### 1.0.1
* matcherBy fix
* type d.ts
* source maps
### 1.0.0
* First version
## LICENSE

@@ -113,0 +105,0 @@ [MIT License](LICENSE)

import rollupPluginTs from "@wessberg/rollup-plugin-ts";
import pkg from './package.json';
import tsconfig from './tsconfig.json';
import { terser } from 'rollup-plugin-terser';

@@ -8,2 +9,3 @@ import builtins from 'rollup-plugin-node-builtins';

const baseConf = {

@@ -63,2 +65,3 @@ input: 'src/diacritic-remover.ts',

tsconfig: {
...tsconfig.compilerOptions,
declaration: false

@@ -65,0 +68,0 @@ }

@@ -6,3 +6,3 @@ import { isString } from "util";

get(target: DiacriticMapperInterface, prop: PropertyKey, receiver: any): any {
if (isString(prop) && prop.length === 1) {
if (isString(prop) && prop.length <= 1) {
return this.diacriticTrap(target, prop);

@@ -13,8 +13,4 @@ }

has(target: DiacriticMapperInterface, prop: PropertyKey): boolean {
return (isString(prop) && prop.length === 1) || Reflect.has(target, prop);
}
protected diacriticTrap(target: DiacriticMapperInterface, char: string): any {
return;
return char;
}

@@ -21,0 +17,0 @@ }

@@ -6,7 +6,12 @@ import DiacriticAbstractHandler from './diacritic-abstract-handler.class';

protected diacriticTrap(target: DiacriticMapperInterface, char: string): string {
super.diacriticTrap(target, char);
const diacritics = target.dictionary[char.toLowerCase()];
return diacritics ? (
diacritics + diacritics.toUpperCase()
) : char;
const lowerCaseChar = super.diacriticTrap(target, char).toLowerCase();
const insensitiveMatcher = new Set<string>([lowerCaseChar, lowerCaseChar.toUpperCase()]);
const diacritics = target.dictionary[lowerCaseChar] || '';
[...diacritics]
.forEach(diacritic => {
insensitiveMatcher.add(diacritic);
insensitiveMatcher.add(diacritic.toUpperCase());
});
return [...insensitiveMatcher].sort().join('');
}

@@ -13,0 +18,0 @@ }

@@ -24,15 +24,17 @@ import DiacriticSetInterface from '../interfaces/diacritic-set.interface';

public constructor(dictionaries: DiacriticSetInterface[]) {
const dictionary = dictionaries.reduce((accumulator: DiacriticSetInterface, currentDict: DiacriticSetInterface) => {
Object.entries(currentDict).forEach(([letter, diacritics]) => {
if (isString(diacritics)){
if (letter in accumulator) {
const newDiacritics = diacritics.split('').filter(l => !accumulator[letter].includes(l)).join('');
accumulator[letter] += newDiacritics;
} else {
accumulator[letter] = diacritics;
}
}
const dictionary = dictionaries
.reduce((
dictMerge: DiacriticSetInterface,
currentDict: DiacriticSetInterface
) => Object.entries(currentDict)
.reduce((accumulator: DiacriticSetInterface, [letter, diacritics]) => ({
...accumulator,
[letter]: (accumulator[letter] || '') + diacritics
}), dictMerge),
{});
Object.entries(dictionary)
.forEach(([letter, diacritics]) => {
dictionary[letter] = [...(new Set([...diacritics]))].sort().join('');
});
return accumulator;
}, {});

@@ -49,7 +51,7 @@ this.dictionary = Object.freeze(dictionary);

.filter(([key, value]) => value && regexp.test(key))
.map(([,value]) => value);
.map(([char ,value]) => char + value);
const upperCase = Object.entries(this.dictionary)
.filter(([key, value]) => value && regexp.test(key.toUpperCase()))
.map(([,value]) => value.toUpperCase());
.map(([char ,value]) => (char + value).toUpperCase());

@@ -56,0 +58,0 @@ return [...lowerCase, ...upperCase].join('');

@@ -6,8 +6,9 @@ import DiacriticAbstractHandler from './diacritic-abstract-handler.class';

protected diacriticTrap(target: DiacriticMapperInterface, char: string): string {
super.diacriticTrap(target, char);
let matcher = super.diacriticTrap(target, char);
const diacritics = target.dictionary[char.toLowerCase()];
if (diacritics) {
return target.isUpperCase(char) ? diacritics.toUpperCase() : diacritics;
matcher+= target.isUpperCase(matcher) ? diacritics.toUpperCase() : diacritics;
}
return char;
return matcher;
}

@@ -14,0 +15,0 @@ }

@@ -11,8 +11,8 @@ import DiacriticMapperInterface from '../interfaces/diacritic-mapper.interface';

const plainChar = Object.keys(target.dictionary)
.find(c => isString(target.dictionary[c]) && target.dictionary[c].includes(lowerCaseChar));
const [plainChar] = Object.entries(target.dictionary)
.find(([, diacritics]) => isString(diacritics) && diacritics.includes(lowerCaseChar)) || [];
if (upperCase && plainChar) {
return plainChar.toUpperCase();
}
return plainChar || char;
return isString(plainChar) ? plainChar : char;
}

@@ -19,0 +19,0 @@ }

@@ -7,3 +7,3 @@ import DiacriticRemoverHandler from './diacritic-remover-handler.class';

class DiacriticRemover extends DiacriticMapperCore{
class DiacriticRemover extends DiacriticMapperCore {
[letter: string]: string|any;

@@ -10,0 +10,0 @@ constructor(...dictionaries: DiacriticSetInterface[]) {

{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES2015", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
// "lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "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. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./dist/test", /* Concatenate and emit output to single file. */
// "outDir": "./", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
// "experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
// "emitDecoratorMetadata": true, /* Enables experimental support for emitting type metadata for decorators. */
"target": "ES2015",
"module": "commonjs",
"declaration": true,
"downlevelIteration": true,
"strict": true,
"noImplicitAny": true,
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true

@@ -63,0 +12,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc