UNPKG

@solid/community-server

Version:

Community Solid Server: an open and modular implementation of the Solid specifications

34 lines 1.11 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toPredicateTerm = void 0; exports.isTerm = isTerm; exports.toNamedTerm = toNamedTerm; exports.toObjectTerm = toObjectTerm; exports.toLiteral = toLiteral; const n3_1 = require("n3"); /** * @param input - Checks if this is a {@link Term}. */ function isTerm(input) { return Boolean(input) && typeof input.termType === 'string'; } function toNamedTerm(subject) { return typeof subject === 'string' ? n3_1.DataFactory.namedNode(subject) : subject; } exports.toPredicateTerm = toNamedTerm; function toObjectTerm(object, preferLiteral = false) { if (typeof object === 'string') { return preferLiteral ? n3_1.DataFactory.literal(object) : n3_1.DataFactory.namedNode(object); } return object; } /** * Creates a literal by first converting the dataType string to a named node. * * @param object - Object value. * @param dataType - Object data type (as string). */ function toLiteral(object, dataType) { return n3_1.DataFactory.literal(`${object}`, dataType); } //# sourceMappingURL=TermUtil.js.map