lincd
Version:
LINCD is a JavaScript library for building user interfaces with linked data (also known as 'structured data', or RDF)
42 lines • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Debug = void 0;
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
const models_1 = require("../models");
class Debug {
//TODO: move stuff back into actual models, keep a general method here that handles numbers etc, so that imports of this file are minimal
//TODO: and so that dprint is not undefined if this file is not imported from index
static print(node, includeInverseProperties = true) {
if (typeof node == 'number') {
node = models_1.NamedNode.TEMP_URI_BASE + node.toString();
}
if (typeof node == 'string') {
let namedNode = models_1.NamedNode.getNamedNode(node);
if (!namedNode)
return node;
node = namedNode;
}
if (node instanceof Set || Array.isArray(node)) {
let r = [];
node.forEach((item) => r.push(this.print(item)));
return `Set [\n${r.join('\n')}\n]`;
}
if (node instanceof models_1.Literal) {
return node.toString();
}
if (node instanceof models_1.Node) {
return node.print();
}
}
}
exports.Debug = Debug;
//attach dprint to global or window object
let g = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : null;
if (g) {
g['dprint'] = (item, includeIncomingProperties = true) => console.log(Debug.print(item, includeIncomingProperties));
}
//# sourceMappingURL=Debug.js.map