@rdfjs/wrapper
    Preparing search index...

    Type Alias ITermWrapperConstructor<T>

    ITermWrapperConstructor: new (
        term: Term,
        dataset: DatasetCore,
        factory: DataFactory,
    ) => T

    Represents the constructor signature of term mapping classes that extend TermWrapper.

    Used by this library where constructors of mappers are accepted for implementing navigation properties that represent graph patterns on dataset and term wrappers.

    Type Parameters

    • T

      The type of the mapping class whose instance is created.

    Type Declaration

      • new (term: Term, dataset: DatasetCore, factory: DataFactory): T
      • Parameters

        • term: Term

          The underlying term being wrapped.

        • dataset: DatasetCore

          The dataset containing the wrapped term.

        • factory: DataFactory

          The data factory used for creating new terms.

        Returns T

        An instance of the mapping class created when invoking the constructor.

    Mapping classes do not need to define a constructor that matches this signature, because the base class has a publicly accessible, matching constructor.

    Given the mapping

    class Person extends TermWrapper {
    get name(): string {
    return RequiredFrom.subjectPredicate(this, "name", LiteralAs.string)
    }
    }

    class People extends DatasetWrapper {
    [Symbol.iterator](): Iterator<Quad> {
    return this.instancesOf("Person", Person) // 2nd param is an ITermWrapperConstructor
    }
    }

    and the RDF

      [ a <Person> ; <name> "Alice" ; ] .
    [ a <Person> ; <name> "Bob" ; ] .

    this code

    for(const person of new People(dataset, factory)) {
    console.log(person.name)
    }

    will print (not necessarily in this order)

    Alice
    Bob
    

    Given the mapping

    class Book extends TermWrapper {
    get author(): Person {
    return RequiredFrom.subjectPredicate(this, "author", TermAs.instance(Person)) // Person is an ITermWrapperConstructor
    }
    }

    class Person extends TermWrapper {
    get name(): string {
    return RequiredFrom.subjectPredicate(this, "name", LiteralAs.string)
    }
    }

    and the RDF

    <book> <author> [ <name> "Alice" ; ] .
    

    this code

    const dataset =
    const book = new Book("book", dataset, factory)
    console.log(book.author.name)

    will print

    Alice