Parent

handles objects of nodes

Name

Parent

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 Parent

    a new instance

    Name

    Parent

    Access

    public

Properties

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

Methods

  • Iterator

    Allows the instance to be used as an iterator

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

    a key (field name) of the parent

    • next: (() => {
          done: boolean;
          value: string;
      } | {
          done: boolean;
          value?: undefined;
      })
        • (): {
              done: boolean;
              value: string;
          } | {
              done: boolean;
              value?: undefined;
          }
        • Returns {
              done: boolean;
              value: string;
          } | {
              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

    Goes through each of the values in the Object, cleans it, stores it, and returns a new Object

    Parameters

    • Optional value: null | Record<any, any>

      The value to clean

    • Optional level: string[]

    Returns null | Record<any, any>

    the cleaned object values

    Name

    clean

    Access

    public

  • Contains

    Returns whether a specific key exists in the parent

    Parameters

    • key: string

      The key to check the existence of

    Returns boolean

    bool

    Name

    contains

    Access

    public

  • Get

    Returns the node associated with the given key

    Parameters

    • key: string

      The key 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 key

    Name

    get

    Access

    public

  • Keys

    Returns a list of the node names in the parent

    Returns string[]

    a list of keys (field names) in the parent

    Name

    keys

    Access

    public

  • Optional

    Getter/Setter for the optional flag

    Parameters

    • Optional value: boolean

      The value to set

    Returns boolean | void

    bool | void

    Name

    optional

  • Requires

    Sets or gets the require rules used to validate the Parent

    Parameters

    • Optional require: Record<string, string | string[]>

      An Object expressing requirements of fields

    Returns void | Record<string, string[]>

    The object of requirements for get, or void for set

    Name

    requires

    Access

    public

  • 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 Node as an Object in the same format as is used in constructing it

    Returns Record<string, any>

    an object that can be converted to JSON

    Name

    toObject

    Access

    public

  • Valid

    Checks if the passed dict has the right values for this Parent

    Parameters

    • value: null | Record<string, 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

  • 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