Interface Point<Value>

A Haystack point record with a specific curVal type

Type Parameters

  • Value extends HVal

Hierarchy

  • HDict

    Hierarchy

    • Point

Properties

curVal?: Value

Current value of the readTag

id?: HRef

Point record id

Accessors

  • get defName(): string
  • If this dict is for a def then return its name otherwise return an empty string.

    Returns

    The def name or an empty string.

    Returns string

  • get keys(): string[]
  • for (let key of dict.keys) {
    console.log(key)
    }

    Returns

    All keys used in the dict.

    Returns string[]

  • get length(): number
  • console.log('Size: ' + dict.length)
    

    Returns

    The number of entries in the dict.

    Returns number

  • get values(): OptionalHVal<null | HVal>[]
  • for (let value of dict.values) {
    console.log(value.getKind())
    }

    Returns

    All values for the dict.

    Returns OptionalHVal<null | HVal>[]

Methods

  • Iterate over a dict.

    This enables a 'for ... of' loop to be used directly on an iterator.

    Returns

    A new iterator for a dict.

    // Iterate a dict
    for (let row of dict) {
    console.log(row.name)
    console.log(row.value)
    }

    Returns Iterator<HValRow, any, undefined>

  • Return true if the dict matches the specified filter or if the value exists in the dict at least once.

    if (dict.any('site and geoCity == "London"')) {
    ...
    }

    Returns

    True if the property value exists in the dict.

    Throws

    An error for a invalid haystack filter.

    Parameters

    • filter: string | Node | OptionalHVal<null | HVal>

      The haystack value, haystack filter or AST node.

    • Optional cx: Partial<EvalContext>

      Optional haystack filter evaluation context.

    Returns boolean

  • Returns

    The dict as an array like object.

    Returns ArrayLike<HValRow>

  • Clear all entries from the dict.

    // Clear all the entries from the dict.
    dict.clear()

    Returns void

  • Compares two values.

    Returns

    The sort order as negative, 0, or positive.

    Parameters

    • value: unknown

      The value to compare against.

    Returns number

  • Create a diff (difference) dict that can be used in an update.

    This will return a new dict with any changed values and removed tags having an HRemove value.

    Returns

    A diff dict.

    Parameters

    • dict: HDict

      The newly updated dict that will be checked for differences. These differences will be incorporated into the returned dict.

    Returns HDict

  • Value equality check.

    Returns

    True if the value is the same.

    Parameters

    • value: unknown

      The value to test.

    Returns boolean

  • Returns a haystack value from the dict or undefined if it can't be found.

    // Gets the value as an HVal so cast to an HStr.
    const str = dict.get('foo') as HStr

    if (str) {
    // Do something.
    }

    // Method is generic to make it easier on the eye for casting.
    const str1 = dict.get<HStr>('foo')

    Returns

    The value or undefined if it can't be found.

    Type Parameters

    Type Parameters

    • Value extends OptionalHVal<null | HVal>

    Parameters

    • name: string

      The name of the value to find.

    Returns undefined | Value

  • Returns

    The value's kind.

    Returns Kind

  • Returns true if the dict has the specified key.

    if (dict.has('foo')) {
    // Do something
    }

    Returns

    True if the value exists in the dict.

    Parameters

    • name: string

      The name of the key.

    Returns boolean

  • Dump the value to the local console output.

    Returns

    The value instance.

    Parameters

    • Optional message: string

      An optional message to display before the value.

    Returns Point<Value>

  • if (dict.isEmpty()) {
    // There are no entries in the dict.
    }

    Returns

    True when there are no entries in the dict.

    Returns boolean

  • Compares the value's kind.

    Returns

    True if the kind matches.

    Parameters

    • kind: Kind

      The kind to compare against.

    Returns boolean

  • Returns true if this dict is newer than the specified dict. The mod timestamp is used to perform the check.

    Returns

    True if this dict is newer.

    Parameters

    • dict: HDict

      The other dict to compare to this dict.

    Returns boolean

  • Returns true if the haystack filter matches the value.

    This method is the same as any.

    if (dict.matches('site and geoCity == "London"')) {
    // Do something
    }

    Returns

    True if the filter matches ok.

    Parameters

    • filter: string | Node

      The filter to test.

    • Optional cx: Partial<EvalContext>

      Optional haystack filter evaluation context.

    Returns boolean

  • Returns

    Returns a copy of the dict.

    Returns HDict

  • Return a reflected array of children prototypes.

    If a namespace isn't specified then the default environment namespace will be used.

    Returns

    An array of dicts.

    Parameters

    • Optional namespace: HNamespace

      An optional namespace to perform the protos call from.

    Returns HDict[]

  • Analyze this dict and return its implemented defs.

    If a namespace isn't specified then the default environment namespace will be used.

    Returns

    An array of dicts.

    Parameters

    • Optional namespace: HNamespace

      An optional namespace to perform the reflect from.

    Returns Reflection

  • Removes a property from the dict.

    // Removes the tag named foo.
    dict.remove('foo')

    Parameters

    • name: string

      The property name.

    Returns void

  • Set a haystack value.

    dict.set('foo', HStr.make('New value'))

    // Set the value using Hayson
    dict.set('foo', 'New value')

    Returns

    The dict instance.

    Parameters

    • name: string

      The name to set.

    • value: HaysonVal | HVal

      The haystack value to set.

    Returns Point<Value>

  • Returns

    An Axon encoded string.

    Returns string

  • Returns

    The value as a dict.

    Returns HDict

  • Get the display string for the dict or the given tag. If 'name' is undefined, then return display text for the entire dict. If 'name' is non-null then format the tag value. If 'name' is not defined by this dict then return 'def'.

    // Returns the record's dis tag string value...
    myDict.toDis()

    // Returns the record's tag value string value for foo...
    myDict.toDis({ name: 'foo' })

    // Returns a localized string based on `disKey`...
    myDict.toDis({
    i18n: (pod: string, key: string): string | undefined => pods.get(pod)?.key(key)
    })

    See

    dictToDis

    Returns

    The display string

    Parameters

    • Optional __namedParameters: { def?: string; i18n?: LocalizedCallback; name?: string }
      • Optional def?: string
      • Optional i18n?: LocalizedCallback
      • Optional name?: string

    Returns string

  • Encodes to an encoded zinc value that can be used in a haystack filter string.

    A dict isn't supported in filter so throw an error.

    Returns

    The encoded value that can be used in a haystack filter.

    Returns string

  • // Convert the dict to an HGrid with one row.
    const hgrid = dict.toGrid()

    Returns

    The dict as a grid.

    Returns HGrid<HDict>

  • Returns

    A JSON reprentation of the object.

    Returns HaysonDict

  • Returns

    A JSON v3 representation of the object.

    Returns JsonV3Dict

  • // Convert the dict to an HList of haystack strings.
    const hlist = dict.toList<HStr>()

    Returns

    All the dict's values as a haystack list

    Type Parameters

    Type Parameters

    • Value extends HVal<Value>

    Returns HList<Value>

  • Returns the underlying object being managed by the store.

    // Gets a JS Object with the keys as strings and the values as HVals.
    const obj = dict.toObj()

    Returns

    A the underlying object.

    Returns HValObj

  • Returns

    A string representation of the value.

    Returns string

  • Encodes to an encoding zinc value.

    Returns

    The encoded zinc string.

    Returns string

  • Update a dict from another dict(s) or Hayson dict(s).

    dict.update(otherDict, anotherDict)

    // Update using a Hayson object
    dict.update({ dis: 'A new display string', curVal: 20 })

    Returns

    The dict instance.

    Parameters

    • Rest ...dicts: (HaysonDict | HDict)[]

      The dicts to update from.

    Returns Point<Value>

  • Iterates through the dict to ensure we have a valid set of haystack values.

    As the dict's internals are directly exposed calling this method will ensure all the values held in the dict are valid haystack values.

    Returns void

Generated using TypeDoc