-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtoml-V4Savzlc.js
More file actions
3 lines (3 loc) · 950 Bytes
/
toml-V4Savzlc.js
File metadata and controls
3 lines (3 loc) · 950 Bytes
1
2
3
/*! (c) Andrea Giammarchi - ISC */
const{isArray:e}=Array,{parse:r}=JSON,s=(e,{s:r})=>e.replace(/"s(\d+)"/g,(e,s)=>r[s]),t=(e,s)=>r(e.replace(/(\S+?)\s*=/g,'"$1":'),(e,r)=>"string"==typeof r?s[r[0]][r.slice(1)]:r),l=(r,t,l,p)=>{for(let c=0,{length:a}=r,n=a-1;c<a;c++){const a=s(r[c],t);l=l[a]||(l[a]=p&&c===n?[]:{}),e(l)&&(c!==n&&l.length||l.push({}),l=l.at(-1))}return l},p=e=>{const r={},[p,c]=((e,r,s)=>[e.replace(/(["'])(?:(?=(\\?))\2.)*?\1/g,e=>`"s${r.push(e.slice(1,-1))-1}"`).replace(/\d{2,}([:-]\d{2}){2}([ T:-][\dZ:-]+)?/g,e=>`"d${s.push(new Date(e))-1}"`).replace(/([,[])\s*[\r\n]+/g,"$1 ").replace(/[\r\n]+\s*]/g,"]").replace(/,\s*]/g,"]"),{s:r,d:s}])(e,[],[]);let a,n,g=r;for(a of p.split(/[\r\n]+/))(a=a.trim())&&"#"!==a[0]&&((n=/^(\[+)(.*?)\]+/.exec(a))?g=l(n[2].trim().split("."),c,r,"["!==n[1]):(n=/^(\S+?)\s*=([^#]+)/.exec(a))&&(g[s(n[1],c)]=t(n[2].trim(),c)));return r};export{p as parse};
//# sourceMappingURL=toml-V4Savzlc.js.map