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.
26 lines • 746 B
JavaScript
export function unwrap(obj) {
if (isUnwrappable(obj)) {
return unwrap(obj.value);
}
else if (isObject(obj)) {
const source = obj;
const target = {};
const keys = Object.keys(obj);
for (const key of keys)
target[key] = unwrap(source[key]);
return target;
}
else if (obj instanceof Array) {
return obj.map(item => unwrap(item));
}
else {
return obj;
}
}
function isObject(obj) {
return typeof obj === "object" && obj !== null && !(obj instanceof Array) && !(obj instanceof Date);
}
function isUnwrappable(obj) {
return isObject(obj) && obj.hasOwnProperty("value") && obj.hasOwnProperty("nodes");
}
//# sourceMappingURL=unwrap.js.map