{"version":3,"file":"index.modern.mjs","sources":["../src/index.ts"],"sourcesContent":["function arrayOrObj(key: string | number): [] | Record<string, any> {\r\n  const char = (key + \"\").charCodeAt(0);\r\n  return char < 48 || char > 57 ? {} : [];\r\n}\r\nexport function unflatto<Input extends Record<string, any>, Output = unknown>(\r\n  input: Input,\r\n  seperator?: string\r\n): Output {\r\n  let i = 0,\r\n    ancestor: any,\r\n    chunk: string,\r\n    keys: string[],\r\n    parent: any,\r\n    currentKey: string,\r\n    nextKey: string,\r\n    cValue: any;\r\n  seperator = seperator || \".\";\r\n  for (chunk in input) {\r\n    i = 0;\r\n    nextKey = \"\";\r\n    keys = chunk.split(seperator);\r\n    parent = ancestor || arrayOrObj(keys[0]);\r\n    ancestor = ancestor || parent;\r\n    for (; i < keys.length; i++) {\r\n      currentKey = nextKey || keys[i];\r\n      if (\r\n        currentKey === \"prototype\" ||\r\n        currentKey === \"__proto__\" ||\r\n        currentKey === \"constructor\"\r\n      ) {\r\n        break;\r\n      }\r\n      nextKey = keys[i + 1];\r\n      if (currentKey in parent) {\r\n        parent = parent[currentKey];\r\n      } else {\r\n        cValue = nextKey ? arrayOrObj(nextKey) : input[chunk];\r\n        parent[currentKey] = cValue;\r\n        parent = cValue;\r\n      }\r\n    }\r\n  }\r\n  return ancestor;\r\n}\r\n"],"names":["arrayOrObj","key","char","charCodeAt","unflatto","input","seperator","ancestor","chunk","keys","parent","currentKey","nextKey","cValue","i","split","length"],"mappings":"AAAA,SAASA,EAAWC,GAClB,MAAMC,GAAQD,EAAM,IAAIE,WAAW,GACnC,OAAOD,EAAO,IAAMA,EAAO,GAAK,CAAA,EAAK,EACvC,UACgBE,EACdC,EACAC,GAEA,IACEC,EACAC,EACAC,EACAC,EACAC,EACAC,EACAC,EAPEC,EAAI,EASR,IAAKN,KADLF,EAAYA,GAAa,IACXD,EAMZ,IALAS,EAAI,EACJF,EAAU,GACVH,EAAOD,EAAMO,MAAMT,GACnBI,EAASH,GAAYP,EAAWS,EAAK,IACrCF,EAAWA,GAAYG,EAChBI,EAAIL,EAAKO,SACdL,EAAaC,GAAWH,EAAKK,GAEZ,cAAfH,GACe,cAAfA,GACe,gBAAfA,GALoBG,IAStBF,EAAUH,EAAKK,EAAI,GACfH,KAAcD,EAChBA,EAASA,EAAOC,IAEhBE,EAASD,EAAUZ,EAAWY,GAAWP,EAAMG,GAC/CE,EAAOC,GAAcE,EACrBH,EAASG,GAIf,OAAON,CACT"}