Base Node

The base class for most Node types

Name

Base

Access

public

Hierarchy (view full)

Constructors

  • Constructor

    Initialises the instance

    Parameters

    • details: Record<string, any>[]

      Node structure

    • Optional extend: false | Record<string, any>[]

      Extend the base node structure, if false, don't copy the base node structure details

    Returns Options

    a new instance

    Name

    Options

    Access

    public

Properties

_class: string
_nodes: Base[]
_optional: boolean
_special: Record<string, any>
validationFailures: string[][]

Accessors

  • get length(): number
  • Length (get)

    Returns the number of nodes in the array of options

    Returns number

    the number of nodes available as options

    Name

    length

    Access

    public

Methods

  • Iterator

    Allows the instance to be used as an iterator

    Returns {
        next: (() => {
            done: boolean;
            value: Base;
        } | {
            done: boolean;
            value?: undefined;
        });
    }

    Object

    • next: (() => {
          done: boolean;
          value: Base;
      } | {
          done: boolean;
          value?: undefined;
      })
        • (): {
              done: boolean;
              value: Base;
          } | {
              done: boolean;
              value?: undefined;
          }
        • Returns {
              done: boolean;
              value: Base;
          } | {
              done: boolean;
              value?: undefined;
          }

    Name

    [Symbol.iterator]

  • Class

    Returns a string representation of the Node's class

    Returns string

    string

    Name

    class

    Access

    public

  • Clean

    Uses the valid method to check which type the value is, and then calls the correct version of clean on that node

    Parameters

    • Optional value: any

      The value to clean

    • Optional level: string[]

    Returns null | Record<any, any>

    the cleaned object values

    Name

    clean

    Access

    public

  • Get

    Returns the node associated with the given index

    Parameters

    • index: number

      The index associated with the node to get

    • Optional def: Base

      If set, returned when a node is not found

    Returns Base

    the child node associated with the index

    Name

    get

    Access

    public

  • Optional

    Getter/Setter for the optional flag

    Parameters

    • Optional value: boolean

      The value to set

    Returns boolean | void

    bool | void

    Name

    optional

  • Special

    Getter/Setter method for special values associated with nodes that are not fields. To retrieve a value or values, pass only the name or names, to set a single special value, pass a name and value

    Parameters

    • name: string

      The name of the value to either set or get

    • Optional value: any

      The value to set, must be something that can be converted directly to JSON

    Returns any

    mixed | void

    Name

    special

    Access

    public

  • To JSON

    Returns a JSON string representation of the instance

    Returns string

    json reprentation of the node

    Name

    toJSON

    Access

    public

  • To Object

    Returns the Nodes as a list of dictionaries in the same format as is used in constructing them

    Returns Record<string, any>[]

    a list of the available nodes as objects that can be represented by json

    Name

    toObject

    Access

    public

  • Valid

    Checks if a value is valid based on the instance's values

    Parameters

    • value: any

      The value to validate

    • Optional level: string[]

      Names of parents to this node

    Returns boolean

    if the value is valid or not

    Name

    valid

    Access

    public

  • Create

    Figure out the child node type necessary and create an instance of it

    Parameters

    • details: Record<string, any>

      An object describing a data point

    Returns Base

    any

    Name

    create

    Access

    public

    Static

  • Register

    Registers the classes that can be children because we can't require them in this file as webpack can't handle file A that requires file B that requires file A

    Parameters

    • name: string | object

      Name / value object of all classes to register, or the name of the constructor that will be added

    • Optional constructor: any

      The class to associate with the given name

    Returns void

    Name

    register

    Access

    public

    Static