If this dict is for a def then return its name otherwise return an empty string.
The def name or an empty string.
for (let key of dict.keys) {
console.log(key)
}
All keys used in the dict.
console.log('Size: ' + dict.length)
The number of entries in the dict.
for (let value of dict.values) {
console.log(value.getKind())
}
All values for the dict.
Iterate over a dict.
This enables a 'for ... of' loop to be used directly on an iterator.
A new iterator for a dict.
// Iterate a dict
for (let row of dict) {
console.log(row.name)
console.log(row.value)
}
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"')) {
...
}
True if the property value exists in the dict.
An error for a invalid haystack filter.
The haystack value, haystack filter or AST node.
Optional
cx: Partial<EvalContext>Optional haystack filter evaluation context.
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.
A diff dict.
The newly updated dict that will be checked for differences. These differences will be incorporated into the returned dict.
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')
The value or undefined if it can't be found.
The name of the value to find.
Dump the value to the local console output.
The value instance.
Optional
message: stringAn optional message to display before the value.
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
}
True if the filter matches ok.
The filter to test.
Optional
cx: Partial<EvalContext>Optional haystack filter evaluation context.
Return a reflected array of children prototypes.
If a namespace isn't specified then the default environment namespace will be used.
An array of dicts.
Optional
namespace: HNamespaceAn optional namespace to perform the protos call from.
Analyze this dict and return its implemented defs.
If a namespace isn't specified then the default environment namespace will be used.
An array of dicts.
Optional
namespace: HNamespaceAn optional namespace to perform the reflect from.
Set a haystack value.
dict.set('foo', HStr.make('New value'))
// Set the value using Hayson
dict.set('foo', 'New value')
The dict instance.
The name to set.
The haystack value to set.
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)
})
dictToDis
The display string
Optional
__namedParameters: { def?: string; i18n?: LocalizedCallback; name?: string }Optional
def?: stringOptional
i18n?: LocalizedCallbackOptional
name?: stringUpdate 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 })
The dict instance.
Rest
...dicts: (HaysonDict | HDict)[]The dicts to update from.
Generated using TypeDoc
A dict resolvable to an HVal that represents server side state.