Options
All
  • Public
  • Public/Protected
  • All
Menu

@thi.ng/rstream-query

Index

Type aliases

BindFn

BindFn: Fn<Solution, any>

PathPattern

PathPattern: [any, any[], any]

Pattern

Pattern: [any, any, any]

QuerySolution

QuerySolution: ISubscription<any, Solutions>

Solution

Solution: IObjectOf<any>

Solutions

Solutions: Set<Solution>

SubQuerySpec

Triple

Triple: Pattern

TripleIds

TripleIds: Set<number>

Triples

Triples: Set<Pattern>

Variables

Let LOGGER

LOGGER: ILogger = ...

Functions

Const asTriples

  • asTriples(obj: any, subject?: any): IterableIterator<any[]>
  • Converts given object into an iterable of triples, with the following conversion rules:

    • Toplevel object keys are used as subjects and MUST each have a plain object as value, where its keys are used as predicates and values as objects (in the SPO sense).
    • Plain objects in SPO object position are translated into unique IDs in order to allow the nested map to become a subject itself. In RDF terms, this is equivalent to BNodes.
    • Arrays in SPO object position cause multiple triples with same subject & predicate to be emitted. If any of the items in the array is a plain object, it will be treated as BNode and transformed as described in the previous rule
    example
    src = {
      "@thi.ng/rstream-query": {
        type: "project",
        author: "toxi",
        tag: ["ES6", "TypeScript", "graph"]
      },
      toxi: {
        type: "person",
        hasAccount: [
          {type: "twitter", id: "toxi"},
          {type: "github", id: "postspectacular"}
        ]
      }
    };
    
    [...asTriples(src)]
    // [ [ '@thi.ng/rstream-query', 'type', 'project' ],
    //   [ '@thi.ng/rstream-query', 'author', 'toxi' ],
    //   [ '@thi.ng/rstream-query', 'tag', 'ES6' ],
    //   [ '@thi.ng/rstream-query', 'tag', 'TypeScript' ],
    //   [ '@thi.ng/rstream-query', 'tag', 'graph' ],
    //   [ 'toxi', 'type', 'person' ],
    //   [ 'toxi', 'hasAccount', '__b0__' ],
    //   [ '__b0__', 'type', 'twitter' ],
    //   [ '__b0__', 'id', 'toxi' ],
    //   [ 'toxi', 'hasAccount', '__b1__' ],
    //   [ '__b1__', 'type', 'github' ],
    //   [ '__b1__', 'id', 'postspectacular' ] ]
    

    Parameters

    • obj: any

      -

    • Optional subject: any

      internal use only, do not specify!

    Returns IterableIterator<any[]>

Const autoQVar

  • autoQVar(): string

Const isAutoQVar

  • isAutoQVar(x: any): boolean
  • Parameters

    • x: any

    Returns boolean

Const isQVar

  • isQVar(x: any): boolean
  • Parameters

    • x: any

    Returns boolean

Const patternVarCount

  • patternVarCount(p: Pattern): number

Const patternVars

  • patternVars(__namedParameters: Pattern): string[]

Const qvarName

  • qvarName(x: string): string
  • Parameters

    • x: string

    Returns string

Const qvarResolver

  • qvarResolver(vs: boolean, vp: boolean, vo: boolean, s: string, p: string, o: string): undefined | ((f: Pattern) => {})
  • Returns an optimized query variable solution extractor function based on given pattern type. vs, vp, vo are flags to indicate if s, p and/or o pattern items are query variables. The returned fn will be optimized to 1 of the 8 possible case and accepts a single fact to extract the respective variables from.

    Parameters

    • vs: boolean

      -

    • vp: boolean

      -

    • vo: boolean

      -

    • s: string

      -

    • p: string

      -

    • o: string

      -

    Returns undefined | ((f: Pattern) => {})

Const resolvePathPattern

  • resolvePathPattern(__namedParameters: PathPattern, maxLen?: number): [Pattern[], string[]]
  • Takes a path triple pattern and max depth. The pattern's predicate must be a seq of preds. Returns a 2-elem vector [patterns vars], where patterns is a list of generated sub-query patterns with injected temp qvars for in between patterns and vars are the temp qvars themselves.

    Example:

    ["?s", [p1, p2, p3], "?o"] =>
    [
      [["?s", p1, "?__q0"], ["?__q0", p2, "?__q1"], ["?__q1", p3, "?o"] ],
      ["?__q0", "?__q1"]
    ]
    

    Parameters

    Returns [Pattern[], string[]]

Const setLogger

  • setLogger(logger: ILogger): ILogger
  • Parameters

    • logger: ILogger

    Returns ILogger

Const sortPatterns

Generated using TypeDoc