syphonx-core
Version:
SyphonX is a template-driven solution for extracting data from HTML in a highly efficient way. It combines the power of jQuery, Regular Expressions, and Javascript into a declarative template-driven format that extracts and reshapes HTML data into JSON.
21 lines • 526 B
JavaScript
export function unwind(obj) {
const [key] = Object.keys(obj);
if (key.includes(".")) {
const value = obj[key];
const keys = key.split(".");
obj = {};
let p = obj;
for (const k of keys) {
const lastOne = keys.indexOf(k) === keys.length - 1;
if (!lastOne) {
p[k] = {};
p = p[k];
}
else {
p[k] = value;
}
}
}
return obj;
}
//# sourceMappingURL=unwind.js.map