Traqula docs
    Preparing search index...

    A TransformerSubTyped specialized for the SPARQL 1.1 AST node types. Provides a type-safe visitor/transformer that dispatches based on node type and subType fields.

    const transformer = new AstTransformer();
    transformer.transformNodeSpecific<'safe', typeof ast>(ast, {
    query: { select: (node) => { ... } },
    });

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    defaultContext: TransformContext
    defaultNodePreVisitor: DefaultNodePreVisitor<Nodes>
    maxNodeRewrites: number

    The number of times transformObjectPreOrder may hand the same position in the tree back to the traversal - by remapping it, or by wrapping it in an array - before we assume the rules do not converge.

    maxStackSize: number

    Methods

    • Protected

      Function to shallow clone any type.

      Type Parameters

      • T

      Parameters

      • obj: T

      Returns T

    • Recursively transforms all objects that are not arrays. Mapper is called on deeper objects first.

      Parameters

      • startObject: object

        object to start iterating from

      • postMapper: (copy: object, orig: object) => unknown

        postMapper to transform the various objects - argument is a copy of the original

      • OptionalpreVisitor: (orig: object) => TransformContext

        callback that is evaluated before iterating deeper. If continues is false, we do not iterate deeper, current object is still mapped. - default: true If shortcut is true, we do not iterate deeper, nor do we branch out, this postMapper will be the last one called.

        • Default false

      Returns unknown

    • Recursively transforms all objects that are not arrays, calling the preMapper on an object before iterating into its descendants, and iterating into the result of that preMapper. It should be noted that the preMapper is called using a shallow copy of the object. Meaning manipulation of nested objects changes the original!

      Parameters

      • startObject: object

        object to start iterating from

      • preMapper: (copy: object, orig: object) => PreOrderMappingReturn

        mapper to transform the various objects - first argument is a copy of the original if default setup says to copy. It returns a PreOrderMappingReturn: the value taking the place of the object - the value we iterate into - together with the TransformContext steering that iteration. Since the mapper is the one deciding what the descendants of that value are, it hands us that context itself, there is no separate preVisitor. Whether we copy is therefore not up to the mapper either, the default context of this transformer decides that. The returned value is only handed back to the traversal - and thus mapped again - when the mapper asked for TransformContext.reTransform, in any other case we iterate straight into its descendants. An array is the exception: it is never mapped as a whole, its elements are handed back and mapped in turn. Either way the rules have to settle a position within maxNodeRewrites hand-backs of that position, or we assume they do not converge and throw. A VisitContext.shortcut simply ends the traversal - since an object is already mapped when we iterate into it, there is nothing left to unwind - leaving the objects still on the stack in the place they have in the (shallow) copy of their parent.

      Returns unknown

    • Visitor that visits all objects. Visits deeper objects first.

      Parameters

      • startObject: object
      • visitor: (orig: object) => void
      • OptionalpreVisitor: (orig: object) => VisitContext

      Returns void