Iterable data structures.
Install
$ yarn add ida
API
Map
Wrapper on top of native ES6 Map.
from
Converts iterable into Map.
static fromsource: Iterable<readonly >: TMap<K, V>
console.logmap.get'a'// 1
fromAsync
Converts async iterable into Map.
static fromAsyncsource: AsyncIterable<readonly >: Promise<TMap<K, V>>
console.logmap.get'a'// 1
size
Returns Map size.
get size: number
console.logmap.size// 2
clear
Clears Map entries.
clear: this
map.clear console.logmap.size// 0
delete
Deletes Map entry by key.
delete
map.delete'a' console.logmap.get'a'// undefined
has
Checks if Map has a key.
haskey: K: boolean
console.logmap.has'a'// true
get
Returns Map value by key.
getkey: K: V | undefinedgetkey: K, fallbackValue: V: V
console.logmap.get'c'// undefined console.logmap.get'c', 3// 3
set
Sets value for key.
setkey: K, value: V: this
map.set'a', 1 console.logmap.has'a'// true
update
Updates value in Map by key.
updatekey: K, updateFn:V: thisupdatekey: K, updateFn:V, fallbackValue: V: this
map.update'a',value + 10 console.logmap.get'a'// 11 map.update'c',value + 10, 3 console.logmap.get'c'// 13
keys
Returns Map keys wrapped into Ida Set
.
keys: TSet<K>
console.logmap.keys.toArray// ['a', 'b']
values
Returns Map values wrapped into Ida Set
.
values: TSet<V>
console.logmap.values.toArray// [1, 2]
pipe
Pipes Map entries into new Map.
pipe: TMap<K, V>pipefn0:Iterable<readonly >: TMap<K1, V1>// up to 8 functions
console.lognewMap.get'a'// 11 console.lognewMap.get'b'// 12 console.lognewMap.get'c'// undefined
toObject
Converts Map info Object (explicitly stringifying keys).
toObject:
console.logmap.toObject// { a: 1, b: 2 }
toNativeMap
Converts Ida Map into native ES6 Map.
toNativeMap: Map<K, V>
console.logmap.toNativeMap// Map { a → 1, b → 2 }
Set
Wrapper on top of native ES6 Set collection.
from
Converts iterable into Set.
static fromsource: Iterable<T>: TSet<T>
console.logset.has'a'// true
fromAsync
Converts async iterable into Set.
static fromAsyncsource: AsyncIterable<T>: Promise<TSet<T>>
console.logset.has'a'// true
size
Returns Set size.
get size: number
console.logset.size// 2
clear
Clears Set values.
clear: this
set.clear console.logset.size// 0
delete
Deletes Set value.
delete
set.delete'a' console.logset.has'a'// false
has
Checks if Set has a value.
hasvalue: T: boolean
console.logset.has'a'// true
add
Adds a value to Set.
addvalue: T: this
set.add'a' console.logset.had'a'// true
pipe
Pipes Set values into new Set.
pipe: TSet<T>;pipefn0:Iterable<T1>: TSet<T1>// up to 8 functions
console.lognewSet.toArray// [ "a", "b" ]
toArray
Converts Set info Array.
toArray: T
console.logset.toArray// ["a", "b", "c"]
toNativeSet
Converts Ida Set into native ES6 Map.
toNativeSet: Set<T>
console.logset// Set [ "a", "b", "c" ]