Members

(constant) annotationCreatorMatches

Matches an annotation's creator URI against a list of URIs (e.g. from a user).

(constant) annotationCreatorName

Returns the creator name for an annotation.

(constant) annotationCreatorUri

Returns the creator URI for an annotation.

(constant) compareFunctions

An object of compare functions (can be used by array.sort for example).

TODO: Add more functions.

(constant) isValidUri

Checks whether a string is a valid URI.

(constant) normalize

Applies recursive unicode normalization to data.

  • If data is an array, it will recursively normalize all elements of that array.
  • If data is an object, it will recursively normalize all property values of that object.
  • If data is a string, it will apply unicode normalization to that string.
  • If data is of any other type, it will be returned as is.

(constant) userOwnsMapping

Returns true if the user owns the mapping (i.e. is first creator), false if not.

Methods

codePointCompare(left, right) → {number}

Compares two strings by Unicode code point order

Parameters:
NameTypeDescription
leftstring
rightstring
Returns:

Negative, zero, or positive.

Type: 
number

definition(item, options)

Returns the definition of a JSKOS Item as an array. If there is no definition, an empty array will be returned.

Parameters:
NameTypeDescription
item*
optionsobject

options object:

  • language: preferred language

getLanguages()

Get the preference list either from store or from defaults (fallback)

(async) getSHA256Hash(input) → {Promise.<string>}

Returns a hex SHA-256 digest of a UTF-8 input string.

Uses globalThis.crypto.subtle (browsers, Node >= 19). Falls back to webcrypto.subtle for Node 18.

Parameters:
NameTypeDescription
inputstring
Returns:
Type: 
Promise.<string>

languageMapContent(item, prop, options)

Returns the content of a language map for a JSKOS Item.

Parameters:
NameTypeDescription
item*

a JSKOS Item

propstring

property of interest in the item

optionsobject

options object:

  • language: preferred language

mappingRegistryIsStored(registry)

Returns whether a mapping registry has stored mappings (true = database) or not (false = recommendations).

Parameters:
NameTypeDescription
registryobject

JSKOS registry

notation(item, type)

Returns the primary notation for a JSKOS Item. If there is no notation, it will return an empty string. Scheme notations will be uppercased.

Parameters:
NameTypeDescription
itemobject

a JSKOS Item

typestring

type of item (optional)

prefLabel(item, options)

Returns the prefLabel of a JSKOS Item. If there is no label, it will return the URI. If there is no URI, it will return an empty string.

Parameters:
NameTypeDescription
item*
optionsobject

options object:

  • fallbackToUri: return URI if no prefLabel can be found (default: true)
  • language: preferred language

selectLanguage(languageMap)

Selects a language tag from a language map or null if no language was found.

Parameters:
NameTypeDescription
languageMapobject

map to select language tag from