LDkit

function createNamespace
import { createNamespace } from "https://deno.land/x/ldkit/namespaces.ts";

Creates a strongly typed container for Linked Data vocabulary to provide type safe access to all vocabulary terms as well as IDE autocompletion.

Examples

Example 1

import { createNamespace } from "ldkit";

const onto = createNamespace(
  {
    iri: "http://www.example.com/ontology#",
    prefix: "onto:",
    terms: [
      "object",
      "predicate",
      "subject",
    ],
  } as const,
);

console.log(onto.subject); // prints http://www.example.com/ontology#subject
console.log(onto.unknown); // TypeScript error! This term does not exist

Parameters

namespaceSpec: N

Specification of the namespace