2.0.3 • Published 3 years ago

@ontologies/core v2.0.3

Weekly downloads
380
License
MIT
Repository
github
Last release
3 years ago

Ontologies

Never manage a namespace object map again, scrap typo's for well-known ontologies. Like DefinitelyTyped, but for ontologies.

Usage

@ontologies/core

This is a special package which provides a few parts;

  • A default export which is a proxy to the currently assigned global Data Factory.
  • A named export globalSymbol which is a symbol to identify the Data Factory used by the other @ontologies/ packages to create rdf objects with.
  • A named export setup which binds the PlainFactory to the global scope under the globalSymbol identifier if it was previously undefined.
  • A named export globalFactory which should be a reference to the last .
  • A named export PlainFactory which implements the Data Factory interface (with slight adjustments) in a functional way (e.g. no instance methods, but provides an equals function on the factory itself).
  • A named export createNS which you can use to create namespaces with which ease NamedNode creation using the global factory.
  • A small set of types useful for working with RDF.

@ontologies/*

The other packages are generated from their respective ontologies, providing client applications with importable symbols and a named export ns with which custom additional terms can be created within the given namespace.

Usage

With named exports

import { name } from '@ontologies/schema'

console.log(name) // http://schema.org/name

With default export

import schema from '@ontologies/schema'

console.log(schema.name) // http://schema.org/name

Custom terms

import { ns } from '@ontologies/schema'

console.log(ns('extension')) // http://schema.org/extension

Non-js symbols

Dashes in term names are replaced with underscores. The default export contains both the verbatim and the underscored values.

import dcterms, { ISO639_2 } from '@ontologies'

console.log(ISO639_2) // NamedNode(http://purl.org/dc/terms/ISO639-2)
console.log(dcterms.ISO639_2) // NamedNode(http://purl.org/dc/terms/ISO639-2)
console.log(dcterms['ISO639-2']) // NamedNode(http://purl.org/dc/terms/ISO639-2)

Collisions with ES reserved keywords

No reserved object property keys exist for JavaScript object literals, so when using the default export, terms can be accessed directly:

import schema from '@ontologies/schema'

console.log(schema.yield) // NamedNode(http://schema.org/name)

When using the named exports, if a term collides with an ES 5/6 reserved keyword or certain built-in classes, the term is prepended with the symbol of the ontology:

import { name, schemayield } from '@ontologies/schema'

// 'name' is not a JS reserved keyword
console.log(name.value) // "http://schema.org/name"
// 'yield' is a reserved keyword, so the package name is prepended to the js identifier.
console.log(schemayield.value) // "http://schema.org/yield"
2.0.3

3 years ago

2.0.2

4 years ago

2.0.1

5 years ago

2.0.0

5 years ago

2.0.0-10

5 years ago

2.0.0-9

5 years ago

2.0.0-8

5 years ago

2.0.0-7

5 years ago

2.0.0-plain.1

5 years ago

2.0.0-plain.0

5 years ago

2.0.0-6

5 years ago

2.0.0-5

5 years ago

2.0.0-4

5 years ago

2.0.0-3

5 years ago

2.0.0-2

6 years ago

2.0.0-1

6 years ago

2.0.0-0

6 years ago

1.7.2

6 years ago

1.7.1

6 years ago

1.7.0

6 years ago

1.6.0

6 years ago

1.5.2-strict-20

6 years ago

1.5.2-strict-19

6 years ago

1.5.2-strict-18

6 years ago

1.5.2-strict-17

6 years ago

1.5.2-strict-16

6 years ago

1.5.2-strict-15

6 years ago

1.5.2-strict-13

6 years ago

1.5.2-strict-12

6 years ago

1.5.2-strict-11

6 years ago

1.5.2-strict-10

6 years ago

1.5.2-strict-9

6 years ago

1.5.2-strict-8

6 years ago

1.5.2-strict-7

6 years ago

1.5.2-strict-6

6 years ago

1.5.2-strict-5

6 years ago

1.5.2-strict-4

6 years ago

1.5.2-strict-3

6 years ago

1.5.2-strict-2

6 years ago

1.5.2-strict

6 years ago

1.5.2-generic

6 years ago

1.5.1-generic

6 years ago

1.5.0-generic

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago