Features
Configuration Options

Options

The Forest constructor parameter can be an object with any/all/none of these properties:

  • value - the initial value of the Forest. (required)
  • name - an identifier for the Forest.
  • test - a function; will be passed each change, as it is asserted; if it returns anything "truthy" (not zero, null, etc), or it throws, will block the updating of a Leaf.
  • actions - an object of name/function accessible off the .do object property of your Leaf.
  • selectors - a collection of named functions that resolve on each update to return summation of the current value.
  • children - an object (or map) of name/branch ( Leaf instances) pairs.
  • type - if true, then rejects any values that don't match the type (string, number, etc.) of the initial value; alternately, takes one of the type describers:
    • 'string'
    • 'number'
    • 'map'
    • 'object'
    • 'array'
    • 'function'
    • an array of acceptable types; e.g., ['string', 'number']
Last updated on April 8, 2023