@metreeca/core - v0.13.0
    Preparing search index...

    Function compact

    • Converts an IRI to a compact URI, if a declared namespace abbreviates it.

      Turns IRIs such as http://www.w3.org/2000/01/rdf-schema#label into prefixed names such as rdfs:label, for compact use in SPARQL, Turtle or JSON-LD text. If several declared namespaces abbreviate the IRI, the longest one is used. If several prefixes declare that namespace, the first one in code point order is used, whatever the declaration order, so the empty prefix always wins. An IRI has no compact form if it is in no declared namespace, or if the part after the namespace is not a valid local name, as defined for Lexicon. Such IRIs must be written in full.

      Parameters

      • lexicon: Lexicon

        The lexicon to compact against

      • iri: string

        The absolute IRI to compact

      Returns Optional<string>

      The prefixed name abbreviating iri, or undefined if no declared namespace abbreviates it

      expand for the reverse conversion