Last active
November 11, 2022 11:45
-
-
Save igrek8/d6c79d6f97a58416e6cfbaa94bf29046 to your computer and use it in GitHub Desktop.
flatten / unflatten structures
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var flatten;(()=>{var r={666:r=>{function e(r,t,n){return Array.isArray(t)?t.reduce(((t,o,c)=>({...t,...e(r?`${r}[${c}]`:`[${c}]`,o,n)})),{}):t&&"object"==typeof t?Object.entries(t).reduce(((t,[o,c])=>{const u=r?`${r}.${o}`:`${o}`,s=n.ignore?.includes(u);return{...t,...s?{[u]:c}:e(u,c,n)}}),{}):{[r]:t}}r.exports=function(r,t={}){return e(void 0,r,t)}},138:(r,e,t)=>{const n=t(666),o=t(961);r.exports={flatten:n,unflatten:o}},961:r=>{function e(...r){return r.reduce(((r,t)=>(Object.keys(t).forEach((n=>{const o=r[n],c=t[n];Array.isArray(o)&&Array.isArray(c)?r[n]=o.concat(...c):r[n]=o&&"object"==typeof o&&c&&"object"==typeof c?e(o,c):c})),r)),{})}r.exports=function(r){return Object.entries(r).reduce(((r,[t,n])=>e(r,function(r,e){return(t=r,t.match(/(\[\d+\])|([^\.\[]+)/gi)).reverse().reduce(((r,e)=>function(r){return/^\[\d+\]$/.test(r)}(e)?[r]:{[e]:r}),e);var t}(t,n))),{})}}},e={},t=function t(n){var o=e[n];if(void 0!==o)return o.exports;var c=e[n]={exports:{}};return r[n](c,c.exports,t),c.exports}(138);flatten=t})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment