frenchkiss
Advanced tools
Comparing version 0.2.1 to 0.2.2
/** | ||
* @license frenchkiss 0.2.1 | ||
* Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
* @license frenchkiss 0.2.2 | ||
* Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
"use strict";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 i=n.length;for(var f=0;f<i;++f){var s=n[f],c=s[0],a=s[1],l="";if(0===c&&a)l=e(a);else if(1===c)l=r(a.trim());else if(2===c){for(var v=s[2],p=s[3],h=s[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(a,o)+")"}l&&u.push(l)}return u.join("+")||'""'}(u(t),n),i=Object.keys(n),f=i.length,s=[],c=0;c<f;++c)s[c]=i[c]+':f(p["'+i[c]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(f?",m=f?{"+s+"}:{}":"")+";return "+o)}function u(e){for(var r=0,o="",u=e.length,f=[],s=0;s<u;++s){var c=e[s],a=void 0;"{"===c?r++||(a=[0,o]):"}"===c&&(--r||(a=t.test(o)?[1,o]:n.test(o)?i(o):[0,o])),a?(f.push(a),o=""):o+=c}return f.push([0,o]),f}function i(t){for(var e=t.match(n),r=e[1],o="p"===e[2][0].toLowerCase(),i=u(t.replace(n,"")),f=i.length,s=[],c=[0,""],a=0;a<f-1;){var l=i[a++][1].trim(),v=u(i[a++][1]);"other"===l?c=v:o&&"="===l[0]?s.unshift([l,v]):s.push([l,v])}return[2,c,r,s,o]}var f={},s={},c={},a="",l="",v=function(t){return t},p=function(){return""},h=function(t,n){return f[n]&&f[n][t]||s[n]&&"string"==typeof s[n][t]&&(f[n][t]=o(s[n][t]))},g=function t(n,e,r){for(var o=Object.keys(e),u=o.length,i=0;i<u;++i){var f=o[i],s=r+f;"object"==typeof e[f]?(t(n,e[f],s+"."),delete n[f]):n[s]=e[f]+""}},b=function t(n,e,r,o){for(var u=Object.keys(r),i=u.length,f=0;f<i;++f){var s=u[f],c=o+s;"object"==typeof r[s]?t(n,e,r[s],c+"."):n[c]!==r[s]&&(delete e[c],n[c]=r[s]+"")}},y={cache:f,store:s,t:function(t,n,e){var r,o=e||a;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||a)},onMissingKey:function(t){v=t},onMissingVariable:function(t){p=t},locale:function(t){return t&&(a=t),a},fallback:function(t){return t&&(l=t),l},set:function(t,n){g(n,n,""),f[t]={},s[t]=n},unset:function(t){delete f[t],delete s[t]},extend:function(t,n){s[t]||(s[t]={}),f[t]||(f[t]={}),b(s[t],f[t],n,"")},plural:function(t,n){c[t]=n}};module.exports=y; |
/** | ||
* @license frenchkiss 0.2.1 | ||
* Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
* @license frenchkiss 0.2.2 | ||
* Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
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}; | ||
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}}; |
/** | ||
* @license frenchkiss 0.2.1 | ||
* Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
* @license frenchkiss 0.2.2 | ||
* Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
* License: MIT | ||
*/ | ||
var e,t;e=this,t=function(){"use strict";var e=/^\s*\w+\s*$/,t=/^\s*(\w+)\s*,\s*(select|plural)\s*,/i,n=JSON.stringify,r=function(e){return'(p["'+e+'"]||(p["'+e+'"]=="0"?0:"'+e+'" in p?"":v("'+e+'",k,l)))'};function o(e){for(var t={},o=function e(t,o){var f=[];var u=t.length;for(var i=0;i<u;++i){var s=t[i],c=s[0],a=s[1],l="";if(0===c&&a)l=n(a);else if(1===c)l=r(a.trim());else if(2===c){for(var p=s[2],v=s[3],h=s[4],d=v.length,g=0;g<d;++g)h?"="===v[g][0][0]?l+='p["'+p+'"]=='+n(v[g][0].substr(1)):(o[p]=1,l+='m["'+p+'"]=='+n(v[g][0])):l+='p["'+p+'"]=='+n(v[g][0]),l+="?"+e(v[g][1],o)+":";l="("+l+e(a,o)+")"}l&&f.push(l)}return f.join("+")||'""'}(f(e),t),u=Object.keys(t),i=u.length,s=[],c=0;c<i;++c)s[c]=u[c]+':f(p["'+u[c]+'"])';return Function("a","f","k","l","v","var p=a||{}"+(i?",m=f?{"+s+"}:{}":"")+";return "+o)}function f(n){for(var r=0,o="",f=n.length,i=[],s=0;s<f;++s){var c=n[s],a=void 0;"{"===c?r++||(a=[0,o]):"}"===c&&(--r||(a=e.test(o)?[1,o]:t.test(o)?u(o):[0,o])),a?(i.push(a),o=""):o+=c}return i.push([0,o]),i}function u(e){for(var n=e.match(t),r=n[1],o="p"===n[2][0].toLowerCase(),u=f(e.replace(t,"")),i=u.length,s=[],c=[0,""],a=0;a<i-1;){var l=u[a++][1].trim(),p=f(u[a++][1]);"other"===l?c=p:o&&"="===l[0]?s.unshift([l,p]):s.push([l,p])}return[2,c,r,s,o]}var i={},s={},c={},a="",l="",p=function(e){return e},v=function(){return""},h=function(e,t){return i[t]&&i[t][e]||s[t]&&"string"==typeof s[t][e]&&(i[t][e]=o(s[t][e]))},d=function e(t,n,r){for(var o=Object.keys(n),f=o.length,u=0;u<f;++u){var i=o[u],s=r+i;"object"==typeof n[i]?(e(t,n[i],s+"."),delete t[i]):t[s]=n[i]+""}},g=function e(t,n,r,o){for(var f=Object.keys(r),u=f.length,i=0;i<u;++i){var s=f[i],c=o+s;"object"==typeof r[s]?e(t,n,r[s],c+"."):t[c]!==r[s]&&(delete n[c],t[c]=r[s]+"")}};return{cache:i,store:s,t:function(e,t,n){var r,o=n||a;return o&&(r=h(e,o))?r(t,c[o],e,o,v):(o=l)&&(r=h(e,o))?r(t,c[o],e,o,v):p(e,t,n||a)},onMissingKey:function(e){p=e},onMissingVariable:function(e){v=e},locale:function(e){return e&&(a=e),a},fallback:function(e){return e&&(l=e),l},set:function(e,t){d(t,t,""),i[e]={},s[e]=t},unset:function(e){delete i[e],delete s[e]},extend:function(e,t){s[e]||(s[e]={}),i[e]||(i[e]={}),g(s[e],i[e],t,"")},plural:function(e,t){c[e]=t}}},"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).frenchkiss=t(); |
@@ -1,2 +0,2 @@ | ||
Copyright (c) 2018-2019 Koala Interactive, Inc. | ||
Copyright (c) 2018-2020 Koala Interactive, Inc. | ||
@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "frenchkiss", | ||
"version": "0.2.1", | ||
"version": "0.2.2", | ||
"description": "The blazing fast lightweight translation module for javascript", | ||
@@ -5,0 +5,0 @@ "author": "Vincent Thibault <vthibault.mobile@gmail.com>", |
@@ -123,3 +123,3 @@ <div align="center"> | ||
The most used method to returns translation. It's built with performance in mind | ||
The most used method to returns translation. It's built with performance in mind. | ||
Here is what you should know about it : | ||
@@ -126,0 +126,0 @@ |
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
24056