View source

class thx.Maps

Available on all platforms

Extension methods for Maps

Class Fields

static function copyTo<TKey, TValue>(src:IMap<TKey, TValue>, dst:IMap<TKey, TValue>):IMap<TKey, TValue>

Copies all the key/values pairs from src to dst. It overwrites already existing keys in dst if needed.

static function getAlt<TKey, TValue>(map:Map<TKey, TValue>, key:TKey, alt:TValue):TValue

Given a key returns the associated value from map. If the key doesn't exist or the associated value is null, it returns the provided alt value instead.

static function getOption<TKey, TValue>(map:IMap<TKey, TValue>, key:TKey):Option<TValue>

Null-safe get.

static inline function isMap(v:Dynamic):Bool

Returns true if a value is of any type of Map. Equivalent to, IMap).

static function mapValues<TKey, TValueA, TValueB>(map:IMap<TKey, TValueA>, f:TValueA -> TValueB, acc:Map<TKey, TValueB>):Map<TKey, TValueB>

It maps values from one Map instance to another.

static function merge<TKey, TValue>(dest:IMap<TKey, TValue>, sources:Array<IMap<TKey, TValue>>):IMap<TKey, TValue>

Merges 0 or more maps of the same type into a destination map. Successive source maps will overwrite values for the same key from previous sources. The destination map is modified in place, and the destination is also returned from the function. To merge into an empty map, pass a new empty map as the dest argument.

var result1 = map1.merge([map2, map3]); // result1 and map1 should be the same after this.  map2 and map3 are not modified.
var result2 = (new Map() : Map<String, Int>).merge(map1, map2); // map1 and map2 not modified

static function reduce<TKey, TValue, TOut>(map:IMap<TKey, TValue>, f:TOut -> Tuple<TKey, TValue> -> TOut, acc:TOut):TOut

Applies the reduce function on every key/value pair in the map.

static function string<TKey, TValue>(m:IMap<TKey, TValue>):String

static function toObject<T>(map:Map<String, T>):{}

mapToObject transforms a Map<String, T> into an anonymous object.

static function tuples<TKey, TValue>(map:IMap<TKey, TValue>):Array<Tuple2<TKey, TValue>>

Converts a Map into an Array>

static function values<TKey, TValue>(map:IMap<TKey, TValue>):Array<TValue>

Extracts the values of a Map into Array

Toggle inherited fields