Hash type. Maps unique keys to their values. Key-Value pairs are stored and iterated in insertion order. Currently Hash type has several limitations: Hash keys are hashed using internal hash() function which can not be overwritten. The internal hash() function exposed to NGS code but adding implementations or setting "hash" to some other function will not affect operation of Hashes. Hash values are compared using internal is_equal() function which can not be overwritten. Both hash() and is_equal() currently handle only Int, Str and arbitrary objects. Comparison of arbitrary objects is done by comparing their addresses in memory.

Parent types


x = {"a": 1, "b": 2}
# Output:
#   {a=1, b=2}

# Output:
#   ['a','b']

# Output:
#   [1,2]

x = {"a": 1, "b": 2}
x.a = 10
# Output:
#   {a=10, b=2}


Get all attributes and their values as key-value pairs in the resulting Hash.
Get the underlying Hash with all the keys/values of the HashLike. Note: the returned value is not a copy.
Create a Hash from Arr of Arr[2]
Hash(arr:Arr, attr:Str)
TODO. Not sure it's used anywhere. Maybe remove?
Hash(arr:Arr, cb:Fun)
Create a Hash from keys in arr using cb for values calculation
Hash(keys:Arr, values:Arr)
Create a Hash from keys in "keys" and corresponding values in "values"
Hash(arr:Arr, key_attr:Str, val_attr:Str)
Create Hash from Arr of something that has key and value attribute


+(a:Hash, b:Hash)
Add Hashes. Builds new hash with key-value pairs from both a and b. If same key is present in both a and b, the value from b is used.
.(h:Hash, attr:Str)
Get hash key.
.=(h:Hash, attr:Str, v:Any)
Set hash key.
::(h:Hash, k:Any)
::=(h:Hash, k:Any, v:Any)
==(a:Hash, b:Hash)
Compare two Hashes. Hashes must have same keys with same values in same order to return true.
[](h:Hash, k:Any)
Get hash value by key. Throws KeyNotFound.
[]=(h:Hash, k:Any, v:Any)
Set hash value.
Make Arr from Hash. Each key/value pair becomes two-items array:
assert_hash_keys_values(actual:Any, expected:Hash, title:Any=null)
Box(h:Hash, k:Any)
Convert hash value indexed by the given key to a Box
Convert a Hash to NGS code that would produce the given Hash when executed. Not fully functional yet.
collector(h:Hash, body:Fun)
Defines collector { ... collect(...) ... } behaviour for hashes
count(h:Hash, predicate:Any)
Count number of key-value pairs in Hash that satisfy the predicate.
created(rd:ResDef, resources:Arr, props:Hash)
del(h:Hash, k:Any)
Delete hash key. No exception is thrown if key is not found, the deletion is just skipped then.
dflt(h:Hash, k:Any, v:Any)
Set an key in a Hash if it's not already set
Diff(a:Hash, b:Hash)
Compare hashes
each(h:Hash, cb:Fun)
Iterate a Hash.
each_idx_key_val(h:Hash, cb:Fun)
Iterate a Hash.
fetch(filename:Str, parse_hints:Hash={})
read() and parse() the given file
Read standard input and parse() it, passing "source" equals "stdin" hint.
filter(h:Hash, predicate:Any)
Filter hash. Build new hash with kev-value pairs selected by predicate.
filterk(h:Hash, predicate:Any)
Filter hash by keys, keeping matched
filterv(h:Hash, predicate:Any)
Filter hash by values
get(h:Hash, k:Any, dflt:Any)
Get hash value by key or dflt if it does not exist
get(h:Hash, k:Any)
Get hash value by key or null if it does not exist
in(x:Any, h:Hash)
Check key presence in a Hash
Trivial initialization helper for init(o, ...) Sets object fields from the supplied parameters
init(hl:HashLike, h:Hash=null)
init(r:Res, def:ResDef, props:Hash)
init(rd:ResDef, _ngs_tags:Hash)
init(i:HashIter, h:Hash)
Inspect Hash
Get Hash keys as an array
Get number of key-value pairs in a Hash
limit(h:Hash, l:Int)
Truncate a Hash if necessary so it would have maximum l key-value pairs.
map(h:Hash, mapper:Fun)
Map a Hash
mapk(h:Hash, mapper:Fun)
Map Hash keys. Build new Hash with same values as in h but keys mapped by mapper.
mapkv(h:Hash, mapper:Fun)
Map Hash keys and values. Build new Hash with keys and values mapped by mapper.
mapv(h:Hash, mapper:Fun)
Map Hash values. Build new Hash with same keys as in h but values mapped by mapper.
Convert hash values to integers where possible
opt_prop(rd:ResDef, name:Str, props:Hash)
Get optional resource property, looking up in properties first and then in anchor
opt_prop(rd:ResDef, name:Str, props:Hash, cb:Fun)
Run cb with optional resource property if it exists, uses opt_prop(ResDef, Str, Hash)
parse(s:Str, hints:Hash)
Attempt to parse JSON. Uses decode_json().
parse(s:Str, hints:Hash)
EXPERIMENTAL. KVS (key-value separator) hint for parse()
parse(s:Str, hints:Hash)
EXPERIMENTAL. FS (field separator) hint for parse()
parse(s:Str, hints:Hash)
Handle fields_names hint - run parse() and make Arr[Hash] from Arr[Arr] using provided fields_names
parse(s:Str, hints:Hash)
Parse the output of "aws" command. Extracts the array (see "s" below"). For "describe-instances", flattens the instance list.
parse(s:Str, hints:Hash)
Parse the output of "find" command which does not use "-printf". Handles "-print0".
push(t:Table, row_hash:Hash)
rejectk(h:Hash, predicate:Any)
Filter hash by keys, removing matched
rejectv(h:Hash, predicate:Any)
Filter hash by values
req_prop(rd:ResDef, name:Str, props:Hash)
Get resource property, looking up in properties first and then in anchor
shift(h:Hash, k:Any)
Get the given key from a Hash and remove it from the Hash. Underlying h[k] may throw KeyNotFound.
shift(h:Hash, k:Any, dflt:Any)
Get a key from a Hash and remove it from the Hash. If they key is not in the Hash, return dflt
sort(h:Hash, lte:Fun=(a function))
Sort a Hash.
sortk(h:Hash, lte:Fun=(a function))
Sort Hash by keys
Convert "Tags" array in the given AWS resource (typically returned by AWS CLI) into Hash.
Convert Hash to string
Build array of Str where each resulting string is of the form "KEY=VALUE"
subset(smaller:Hash, larger:Hash)
unparse(data:Any, hints:Hash)
Not implemented yet
update(dst:Hash, src:Hash)
Update a Hash with key-value pairs from another Hash. For non destructive version use "dst + src".
update(r:VpcRes, props:Hash)
update(r:IgwRes, props:Hash)
update(r:RouteTableRes, props:Hash)
update(sg:SecGroupRes, props:Hash)
update(r:SubnetRes, props:Hash)
update(r:InstanceRes, props:Hash)
update(elb:ElbRes, props:Hash)
update(rrset:RecordSetRes, props:Hash)
Get Hash values as an array