frenchkiss
Advanced tools
Comparing version 0.2.2 to 0.2.3
/** | ||
* @license frenchkiss 0.2.2 | ||
* @license frenchkiss 0.2.3 | ||
* Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
@@ -4,0 +4,0 @@ * License: MIT |
/** | ||
* @license frenchkiss 0.2.2 | ||
* @license frenchkiss 0.2.3 | ||
* Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
var t=/^\s*\w+\s*$/,n=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,e=JSON.stringify,r=function(t){return'(p["'+t+'"]||(p["'+t+'"]=="0"?0:"'+t+'" in p?"":v("'+t+'",k,l)))'};function o(t){for(var n={},o=function t(n,o){var u=[];var f=n.length;for(var i=0;i<f;++i){var a=n[i],c=a[0],s=a[1],l="";if(0===c&&s)l=e(s);else if(1===c)l=r(s.trim());else if(2===c){for(var v=a[2],p=a[3],h=a[4],g=p.length,b=0;b<g;++b)h?"="===p[b][0][0]?l+='p["'+v+'"]=='+e(p[b][0].substr(1)):(o[v]=1,l+='m["'+v+'"]=='+e(p[b][0])):l+='p["'+v+'"]=='+e(p[b][0]),l+="?"+t(p[b][1],o)+":";l="("+l+t(s,o)+")"}l&&u.push(l)}return u.join("+")||'""'}(u(t),n),f=Object.keys(n),i=f.length,a=[],c=0;c<i;++c)a[c]=f[c]+':f(p["'+f[c]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(i?",m=f?{"+a+"}:{}":"")+";return "+o)}function u(e){for(var r=0,o="",u=e.length,i=[],a=0;a<u;++a){var c=e[a],s=void 0;"{"===c?r++||(s=[0,o]):"}"===c&&(--r||(s=t.test(o)?[1,o]:n.test(o)?f(o):[0,o])),s?(i.push(s),o=""):o+=c}return i.push([0,o]),i}function f(t){for(var e=t.match(n),r=e[1],o="p"===e[2][0].toLowerCase(),f=u(t.replace(n,"")),i=f.length,a=[],c=[0,""],s=0;s<i-1;){var l=f[s++][1].trim(),v=u(f[s++][1]);"other"===l?c=v:o&&"="===l[0]?a.unshift([l,v]):a.push([l,v])}return[2,c,r,a,o]}var i={},a={},c={},s="",l="",v=function(t){return t},p=function(){return""},h=function(t,n){return i[n]&&i[n][t]||a[n]&&"string"==typeof a[n][t]&&(i[n][t]=o(a[n][t]))},g=function t(n,e,r){for(var o=Object.keys(e),u=o.length,f=0;f<u;++f){var i=o[f],a=r+i;"object"==typeof e[i]?(t(n,e[i],a+"."),delete n[i]):n[a]=e[i]+""}},b=function t(n,e,r,o){for(var u=Object.keys(r),f=u.length,i=0;i<f;++i){var a=u[i],c=o+a;"object"==typeof r[a]?t(n,e,r[a],c+"."):n[c]!==r[a]&&(delete e[c],n[c]=r[a]+"")}};export default{cache:i,store:a,t:function(t,n,e){var r,o=e||s;return o&&(r=h(t,o))?r(n,c[o],t,o,p):(o=l)&&(r=h(t,o))?r(n,c[o],t,o,p):v(t,n,e||s)},onMissingKey:function(t){v=t},onMissingVariable:function(t){p=t},locale:function(t){return t&&(s=t),s},fallback:function(t){return t&&(l=t),l},set:function(t,n){g(n,n,""),i[t]={},a[t]=n},unset:function(t){delete i[t],delete a[t]},extend:function(t,n){a[t]||(a[t]={}),i[t]||(i[t]={}),b(a[t],i[t],n,"")},plural:function(t,n){c[t]=n}}; | ||
const t=/^\s*\w+\s*$/,e=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,s=t=>'(p["'+t+'"]||(p["'+t+'"]=="0"?0:"'+t+'" in p?"":v("'+t+'",k,l)))';function o(t){const e={},o=function t(e,o){const l=[];const r=e.length;for(let c=0;c<r;++c){const r=e[c],f=r[0],i=r[1];let u="";if(0===f&&i)u=n(i);else if(1===f)u=s(i.trim());else if(2===f){const e=r[2],s=r[3],l=r[4],c=s.length;for(let r=0;r<c;++r)l?"="===s[r][0][0]?u+='p["'+e+'"]=='+n(s[r][0].substr(1)):(o[e]=1,u+='m["'+e+'"]=='+n(s[r][0])):u+='p["'+e+'"]=='+n(s[r][0]),u+="?"+t(s[r][1],o)+":";u="("+u+t(i,o)+")"}u&&l.push(u)}return l.join("+")||'""'}(l(t),e),r=Object.keys(e),c=r.length,f=[];for(let t=0;t<c;++t)f[t]=r[t]+':f(p["'+r[t]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(c?",m=f?{"+f+"}:{}":"")+";return "+o)}function l(n){let s=0,o="";const l=n.length,c=[];for(let f=0;f<l;++f){const l=n[f];let i;"{"===l?s++||(i=[0,o]):"}"===l&&(--s||(i=t.test(o)?[1,o]:e.test(o)?r(o):[0,o])),i?(c.push(i),o=""):o+=l}return c.push([0,o]),c}function r(t){const n=t.match(e),s=n[1],o="p"===n[2][0].toLowerCase(),r=l(t.replace(e,"")),c=r.length,f=[];let i=[0,""];for(let t=0;t<c-1;){let e=r[t++][1].trim();const n=l(r[t++][1]);"other"===e?i=n:o&&"="===e[0]?f.unshift([e,n]):f.push([e,n])}return[2,i,s,f,o]}const c={},f={};let i={},u="",p="",a=t=>t,h=()=>"";const g=(t,e)=>c[e]&&c[e][t]||f[e]&&"string"==typeof f[e][t]&&(c[e][t]=o(f[e][t])),b=(t,e,n)=>{let s,o=n||u;return o&&(s=g(t,o))?s(e,i[o],t,o,h):(o=p)&&(s=g(t,o))?s(e,i[o],t,o,h):a(t,e,n||u)},y=t=>{a=t},d=t=>{h=t},j=t=>(t&&(u=t),u),k=t=>(t&&(p=t),p),m=(t,e)=>{O(e,e,""),c[t]={},f[t]=e},O=(t,e,n)=>{const s=Object.keys(e),o=s.length;for(let l=0;l<o;++l){const o=s[l],r=n+o;"object"==typeof e[o]?(O(t,e[o],r+"."),delete t[o]):t[r]=e[o]+""}},v=(t,e)=>{i[t]=e},w=(t,e)=>{f[t]||(f[t]={}),c[t]||(c[t]={}),x(f[t],c[t],e,"")},x=(t,e,n,s)=>{const o=Object.keys(n),l=o.length;for(let r=0;r<l;++r){const l=o[r],c=s+l;"object"==typeof n[l]?x(t,e,n[l],c+"."):t[c]!==n[l]&&(delete e[c],t[c]=n[l]+"")}},M=t=>{delete c[t],delete f[t]};export default{cache:c,store:f,t:b,onMissingKey:y,onMissingVariable:d,locale:j,fallback:k,set:m,unset:M,extend:w,plural:v};export{c as cache,f as store,b as t,y as onMissingKey,d as onMissingVariable,j as locale,k as fallback,m as set,v as plural,w as extend,M as unset}; |
/** | ||
* @license frenchkiss 0.2.2 | ||
* @license frenchkiss 0.2.3 | ||
* Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
@@ -4,0 +4,0 @@ * License: MIT |
{ | ||
"name": "frenchkiss", | ||
"version": "0.2.2", | ||
"version": "0.2.3", | ||
"description": "The blazing fast lightweight translation module for javascript", | ||
@@ -5,0 +5,0 @@ "author": "Vincent Thibault <vthibault.mobile@gmail.com>", |
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
24161