@sveltekit-i18n/parser-default
Advanced tools
Comparing version 1.0.0-beta.4 to 1.0.0-rc.0
@@ -1,1 +0,1 @@ | ||
var P=Object.defineProperty;var h=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var F=(i,t,e)=>t in i?P(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,f=(i,t)=>{for(var e in t||(t={}))D.call(t,e)&&F(i,e,t[e]);if(h)for(var e of h(t))U.call(t,e)&&F(i,e,t[e]);return i};var L=(i,t)=>{for(var e in t)P(i,e,{get:t[e],enumerable:!0})};var l={};L(l,{ago:()=>B,date:()=>N,eq:()=>c,gt:()=>C,gte:()=>q,lt:()=>w,lte:()=>V,ne:()=>S,number:()=>j});var s=(i,t,e)=>{var r;return((r=i.find(n=>n.key===t))==null?void 0:r.value)||e};var c=(i,t=[],e="")=>(t.find(({key:r})=>`${r}`.toLowerCase()===`${i}`.toLowerCase())||{}).value||e,S=(i,t=[],e="")=>(t.find(({key:r})=>`${r}`.toLowerCase()!==`${i}`.toLowerCase())||{}).value||e,w=(i,t=[],e="")=>(t.sort((n,o)=>+n.key-+o.key).find(({key:n})=>+i<+n)||{}).value||e,C=(i,t=[],e="")=>(t.sort((n,o)=>+o.key-+n.key).find(({key:n})=>+i>+n)||{}).value||e,V=(i,t=[],e="")=>c(i,t,w(i,t,e)),q=(i,t=[],e="")=>c(i,t,C(i,t,e)),j=(i,t=[],e="",r="")=>r&&new Intl.NumberFormat(r,{maximumFractionDigits:s(t,"decimals",s(t,"maxDecimals","2")),minimumFractionDigits:s(t,"minDecimals")}).format(+i||+e),N=(i,t=[],e="",r="")=>r&&new Intl.DateTimeFormat(r,{dateStyle:s(t,"dateStyle","medium"),timeStyle:s(t,"timeStyle","short")}).format(+i||+e),d=[{key:"second",multiplier:1e3},{key:"minute",multiplier:60},{key:"hour",multiplier:60},{key:"day",multiplier:24},{key:"week",multiplier:7},{key:"month",multiplier:13/3},{key:"year",multiplier:12}],z=i=>d.indexOf(d.find(t=>t.key===i)),A=i=>d.reduce(([t,e],{key:r,multiplier:n},o)=>{if(!e||o===z(e)+1){let m=Math.round(t/n);if(!e||Math.abs(m)>=1)return[m,r]}return[t,e]},[i,""]),B=(i,t=[],e="",r="")=>{if(!r)return"";let n=s(t,"format","auto"),o=(+i||+e)-Date.now(),m=n==="auto"?A(o):[o,n];return new Intl.RelativeTimeFormat(r,{numeric:s(t,"numeric","auto"),style:s(t,"style","long")}).format(...m)};var E=(i="")=>/{{(?:(?!{{|}}).)+}}/.test(`${i}`),p=i=>i.replace(/\\(?=:|;|{|})/g,""),G=(i,t={},e={},r)=>i.replace(/{{\s*(?:(?!{{|}}).)+\s*}}/g,n=>{let o=p(`${n.match(/(?!{|\s).+?(?!\\[:;]).(?=\s*(?:[:;]|}}$))/)}`),m=t==null?void 0:t[o],[,M=""]=n.match(/.+?(?!\\;).;\s*default\s*:\s*([^\s:;].+?(?:\\[:;]|[^;\s}])*)(?=\s*(?:;|}}$))/i)||[],[,a=""]=n.match(/{{\s*(?:[^;]|(?:\\;))+\s*(?:(?!\\:).[:])\s*(?!\s)((?:\\;|[^;])+?)(?=\s*(?:[;]|}}$))/i)||[];if(m===void 0&&a!=="ne")return M;let T=!!a,y=f(f({},l),e||{});a=Object.keys(y).includes(a)?a:"eq";let b=y[a],g=(n.match(/[^\s:;{](?:[^;]|\\[;])+[^\s:;}]/gi)||[]).reduce((k,$,R)=>{if(R>0){let u=p(`${$.match(/(?:(?:\\:)|[^:])+/)}`.trim()),O=`${$.match(/(?:(?:\\:)|[^:])+$/)}`.trim();if(u&&u!=="default"&&O)return[...k,{key:u,value:O}]}return k},[]);return!T&&!g.length?`${m}`:b(m,g,M,r)}),I=(i,t={},e,r)=>{if(E(i)){let n=G(i,t,e,r);return I(n,t,e,r)}else return p(`${i}`)},H=({customModifiers:i={}}={})=>({parse:(t,[e],r,n)=>((e==null?void 0:e.default)&&t===void 0&&(t=`${e.default}`),t===void 0&&(t=`${n}`),I(t,e,i,r))}),X=H;export{X as default}; | ||
var P=Object.defineProperty;var h=Object.getOwnPropertySymbols;var D=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable;var F=(i,t,e)=>t in i?P(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,d=(i,t)=>{for(var e in t||(t={}))D.call(t,e)&&F(i,e,t[e]);if(h)for(var e of h(t))U.call(t,e)&&F(i,e,t[e]);return i};var L=(i,t)=>{for(var e in t)P(i,e,{get:t[e],enumerable:!0})};var p={};L(p,{ago:()=>B,date:()=>N,eq:()=>l,gt:()=>C,gte:()=>q,lt:()=>w,lte:()=>V,ne:()=>S,number:()=>j});var o=(i,t,e)=>{var r;return((r=i.find(n=>n.key===t))==null?void 0:r.value)||e};var l=(i,t=[],e="")=>(t.find(({key:r})=>`${r}`.toLowerCase()===`${i}`.toLowerCase())||{}).value||e,S=(i,t=[],e="")=>(t.find(({key:r})=>`${r}`.toLowerCase()!==`${i}`.toLowerCase())||{}).value||e,w=(i,t=[],e="")=>(t.sort((n,s)=>+n.key-+s.key).find(({key:n})=>+i<+n)||{}).value||e,C=(i,t=[],e="")=>(t.sort((n,s)=>+s.key-+n.key).find(({key:n})=>+i>+n)||{}).value||e,V=(i,t=[],e="")=>l(i,t,w(i,t,e)),q=(i,t=[],e="")=>l(i,t,C(i,t,e)),j=(i,t=[],e="",r="")=>r&&new Intl.NumberFormat(r,{maximumFractionDigits:o(t,"decimals",o(t,"maxDecimals","2")),minimumFractionDigits:o(t,"minDecimals")}).format(+i||+e),N=(i,t=[],e="",r="")=>r&&new Intl.DateTimeFormat(r,{dateStyle:o(t,"dateStyle","medium"),timeStyle:o(t,"timeStyle","short")}).format(+i||+e),c=[{key:"second",multiplier:1e3},{key:"minute",multiplier:60},{key:"hour",multiplier:60},{key:"day",multiplier:24},{key:"week",multiplier:7},{key:"month",multiplier:13/3},{key:"year",multiplier:12}],z=i=>c.indexOf(c.find(t=>t.key===i)),A=i=>c.reduce(([t,e],{key:r,multiplier:n},s)=>{if(!e||s===z(e)+1){let m=Math.round(t/n);if(!e||Math.abs(m)>=1)return[m,r]}return[t,e]},[i,""]),B=(i,t=[],e="",r="")=>{if(!r)return"";let n=o(t,"format","auto"),s=(+i||+e)-Date.now(),m=n==="auto"?A(s):[s,n];return new Intl.RelativeTimeFormat(r,{numeric:o(t,"numeric","auto"),style:o(t,"style","long")}).format(...m)};var E=(i="")=>/{{(?:(?!{{|}}).)+}}/.test(`${i}`),M=i=>i.replace(/\\(?=:|;|{|})/g,""),G=(i,t={},e={},r)=>i.replace(/{{\s*(?:(?!{{|}}).)+\s*}}/g,n=>{let s=M(`${n.match(/(?!{|\s).+?(?!\\[:;]).(?=\s*(?:[:;]|}}$))/)}`),m=t==null?void 0:t[s],[,f=""]=n.match(/.+?(?!\\;).;\s*default\s*:\s*([^\s:;].+?(?:\\[:;]|[^;\s}])*)(?=\s*(?:;|}}$))/i)||[];f=f||(t==null?void 0:t.default)||"";let[,u=""]=n.match(/{{\s*(?:[^;]|(?:\\;))+\s*(?:(?!\\:).[:])\s*(?!\s)((?:\\;|[^;])+?)(?=\s*(?:[;]|}}$))/i)||[];if(m===void 0&&u!=="ne")return f;let T=!!u,g=d(d({},p),e||{});u=Object.keys(g).includes(u)?u:"eq";let b=g[u],y=(n.match(/[^\s:;{](?:[^;]|\\[;])+[^\s:;}]/gi)||[]).reduce((k,$,R)=>{if(R>0){let a=M(`${$.match(/(?:(?:\\:)|[^:])+/)}`.trim()),O=`${$.match(/(?:(?:\\:)|[^:])+$/)}`.trim();if(a&&a!=="default"&&O)return[...k,{key:a,value:O}]}return k},[]);return!T&&!y.length?`${m}`:b(m,y,f,r)}),I=(i,t={},e,r)=>{if(E(i)){let n=G(i,t,e,r);return I(n,t,e,r)}else return M(`${i}`)},H=({customModifiers:i={}}={})=>({parse:(t,[e],r,n)=>((e==null?void 0:e.default)&&t===void 0&&(t=`${e.default}`),t===void 0&&(t=`${n}`),I(t,e,i,r))}),X=H;export{X as default}; |
{ | ||
"name": "@sveltekit-i18n/parser-default", | ||
"version": "1.0.0-beta.4", | ||
"version": "1.0.0-rc.0", | ||
"description": "Default parser for sveltekit-i18n library.", | ||
@@ -18,6 +18,6 @@ "type": "module", | ||
"scripts": { | ||
"dev": "tsup src/index.ts --dts --format cjs,esm --sourcemap --watch", | ||
"dev": "tsup --watch", | ||
"test": "jest", | ||
"build": "tsup src/index.ts --dts --format cjs,esm --minify", | ||
"prepublishOnly": "rm -rf dist && npm run build", | ||
"build": "tsup", | ||
"prepublishOnly": "npm run build", | ||
"lint": "eslint --fix --ext .ts,.js --ignore-path .gitignore ." | ||
@@ -24,0 +24,0 @@ }, |
Sorry, the diff of this file is not supported yet
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
14382