JSKOS Tools.

Classes

ConceptScheme

Members

(static, constant) defaultMappingType

(static, constant) objectTypes

JSKOS Concept Types indexed by primary name.

Methods

(static) addContext(jskos)

Add @context URI to a JSKOS resource or to an array of JSKOS resources.

Parameters:
NameTypeDescription
jskosobject

object or array of objects

(static) addMappingIdentifiers()

(static) clean(jskos)

Recursively cleans JSKOS object by removing properties starting with _ or containing only uppercase letters. Warning: Works directly on the object without creating a copy!

Parameters:
NameTypeDescription
jskosobject

(static) compare(object1, object2)

Compares two objects based on their URIs, using getAllUris.

Parameters:
NameTypeDescription
object1object
object2object

(static) compareMappingMembers()

(static) compareMappings()

(static) compareMappingsDeep()

Compare two mappings based on their properties. Concept sets and schemes are compared by URI.

(static) conceptsOfMapping(mapping, side)

Returns a list of concepts for a mapping.

Parameters:
NameTypeDescription
mapping*
side*

Either from or to. Default is both.

(static) copyDeep(object, replaceCircular, skipUnderscore)

Creates a deep copy of a JSKOS object, replacing possibly circular structures with open world [null] statements. All properties starting with an underscore (_) will be ignored.

Parameters:
NameTypeDefaultDescription
objectobject
replaceCirculararray

additional property names that should be replace with open world [null] statements

skipUnderscorebooltrue

whether to skip properties starting with _ (default true)

(static) csvSerializer()

Returns a function to serialize an array as CSV row as configured. See CSV Dialect (https://frictionlessdata.io/specs/csv-dialect/).

(static) flattenMapping()

(static) getAllUris(object)

Returns all possible URIs for a JSKOS object. Takes into consideration both the uri and identifier properties.

Parameters:
NameTypeDescription
objectobject

(static) guessObjectType(jskos|name|uri, shortname)

Guess the JSKOS Concept Type name from an object or name.

Parameters:
NameTypeDescription
jskos|name|uriobject | string

object or string to guess from

shortnameboolean

return short name if enabled (false by default)

(static) isConcept()

Checks whether JSKOS object is a concept based on type property.

(static) isContainedIn()

Checks whether an object is contained in a list of objects using compare.

(static) isScheme()

Checks whether JSKOS object is a concept scheme based on type property.

(static) mappingCSV(options)

Returns an object of preconfigured conversion functions to convert mappings into CSV.

Parameters:
NameTypeDescription
optionsobject

Possible options:

  • delimiter: delimiter character (default ,)
  • quoteChar: quote character (default ")
  • lineTerminator: line terminator (default \n)
  • type: whether to include mapping type in output (default true)
  • schemes: whether to include scheme notations in output (default false)
  • labels: whether to include concept labels in output (default false)
  • creator: whether to include mapping creator in output (default false)

(static) mappingContentIdentifier()

Returns a mapping content identifier. The identifier starts with urn:jskos:mapping:content: and takes concepts and type into consideration. It uses the mappingContent function to get relevant properties from the mapping.

(static) mappingMembersIdentifier()

(static) mappingTypeByType()

(static) mappingTypeByUri()

(static) matchObjectTypes(a, b)

Checks if two objects have a matching object type. Returns false only if types for both objects could be guessed and they did not match.

Parameters:
NameTypeDescription
aobject
bobject

(static) merge(a, b, options)

Merges two JSKOS objects. Object properties will be merged deeply. Array properties will be combined (and URIs will be used for comparison if it's an array of objects).

The options property allows for different options:

  • mergeUris (boolean, default false) - appends b's URI to the result's identifier property if necessary, removes a's URI from the result's identifier property if necessary (useful for merging ConceptSchemes)
  • detectMismatch (array of strings, default []) - throws an error if the value at a certain path does not match between the two objects (allows for deep properties, e.g. prefLabel.de)
  • skipPaths (array of strings, default []) - provide paths to completely skip when merging
Parameters:
NameTypeDescription
aobject
bobject
optionsobject

optional, see above

(static) mergeUris(a, b)

Merge URIs of two objects a and b into a by adding/removing URIs from identifier property.

Parameters:
NameTypeDescription
aobject
bobject

(static) minifyMapping()

(static) sortConcepts(concepts)

Sorts a list of concepts by their notation, then URI.

Parameters:
NameTypeDescription
concepts*

(static) sortSchemes(schemes)

Sorts a list of schemes by their prefLabel (German or English), then notation, then URI.

Parameters:
NameTypeDescription
schemes*