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.
32 lines • 960 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.unwrap = void 0;
function unwrap(obj) {
if (isUnwrappable(obj)) {
return unwrap(obj.value);
}
else if (isObject(obj)) {
var source = obj;
var target = {};
var keys = Object.keys(obj);
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
var key = keys_1[_i];
target[key] = unwrap(source[key]);
}
return target;
}
else if (obj instanceof Array) {
return obj.map(function (item) { return unwrap(item); });
}
else {
return obj;
}
}
exports.unwrap = unwrap;
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