yoastseo
Version:
Yoast client-side content analysis
28 lines (27 loc) • 712 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = serialize;
var _lodash = require("lodash");
/**
* Serializes a data structure to transfer it over a web worker message.
*
* @param {*} thing The data structure to serialize.
*
* @returns {*} The serialized data structure.
*/
function serialize(thing) {
if ((0, _lodash.isArray)(thing)) {
return thing.map(serialize);
}
const thingIsObject = (0, _lodash.isObject)(thing);
if (thingIsObject && thing.serialize) {
return thing.serialize();
}
if (thingIsObject) {
return (0, _lodash.mapValues)(thing, value => serialize(value));
}
return thing;
}
//# sourceMappingURL=serialize.js.map