UNPKG

semantic-analysis

Version:

Extensible semantic Structured Data analysis library for Microdata and JSON-LD

43 lines 1.45 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toSerializable = void 0; var spec_1 = require("./spec"); var util_1 = require("../../util"); /* Simplification */ exports.toSerializable = function (_a) { var items = _a.items, document = _a.document, logs = _a.logs; return ({ items: items.map(simplifyItem), document: { url: document === null || document === void 0 ? void 0 : document.url }, logs: logs.map(simplifyLog), }); }; var simplifyItem = function (_a) { var type = _a.type, id = _a.id, meta = _a.meta, propMeta = _a.propMeta; return ({ type: type, id: id, meta: simplifyMeta(meta), properties: util_1.map(propMeta, (function (props) { return props.map(function (_a) { var meta = _a.meta, value = _a.value; return ({ meta: simplifyMeta(meta), value: spec_1.isItem(value) ? simplifyItem(value) : value, }); }); })), }); }; var simplifyMeta = function (_a) { var type = _a.type, logs = _a.logs; return ({ type: type, logs: logs.map(simplifyLog), }); }; var simplifyLog = function (_a) { var sort = _a.sort, message = _a.message, phase = _a.phase, term = _a.term; return ({ sort: sort, message: message, phase: phase, term: term }); }; //# sourceMappingURL=serializable.js.map