@tpluscode/rdf-string
Advanced tools
Comparing version 1.3.3 to 1.3.4
@@ -10,5 +10,5 @@ import { BlankNode, Literal, NamedNode } from '@rdfjs/types'; | ||
} | ||
export declare function namedNode(term: NamedNode, { base, prefixes, noPrefixedNames }: NamedNodeOptions): PartialString; | ||
export declare function namedNode(term: Pick<NamedNode, 'value'>, { base, prefixes, noPrefixedNames }: NamedNodeOptions): PartialString; | ||
export declare function literal(term: Literal, { base, prefixes }: NamedNodeOptions): PartialString; | ||
export {}; | ||
//# sourceMappingURL=turtle.d.ts.map |
import { shrink } from '@zazuko/prefixes'; | ||
import { xsd } from '@tpluscode/rdf-ns-builders'; | ||
import TermMap from '@rdfjs/term-map'; | ||
import { mapBuilders } from '../prefixes.js'; | ||
@@ -25,8 +26,11 @@ import * as ntriples from './ntriples.js'; | ||
} | ||
function isBuiltInType(datatype) { | ||
return datatype.equals(xsd.integer) || datatype.equals(xsd.boolean) || datatype.equals(xsd.decimal); | ||
} | ||
const buildInTypes = new TermMap([ | ||
[xsd.integer, /^-?[0-9]+$/], | ||
[xsd.decimal, /^-?[0-9]+\.[0-9]+$/], | ||
[xsd.boolean, /^(true|false)$/], | ||
]); | ||
export function literal(term, { base = '', prefixes = {} }) { | ||
if (!term.language && term.datatype) { | ||
if (isBuiltInType(term.datatype)) { | ||
const shorthandSyntax = buildInTypes.get(term.datatype); | ||
if (shorthandSyntax && shorthandSyntax.test(term.value)) { | ||
return { | ||
@@ -33,0 +37,0 @@ value: term.value, |
{ | ||
"name": "@tpluscode/rdf-string", | ||
"version": "1.3.3", | ||
"version": "1.3.4", | ||
"description": "Simplifies creating of RDF strings using ECMAscript templates", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
46512
762