Immutable.js Flashcards
(191 cards)
List
Create a new immutable _____ containing the values of the provided iterable-like.
\_\_\_\_\_<T>():\_\_\_\_\_<T>\_\_\_\_\_<T>(iter: IndexedIterable<T>):\_\_\_\_\_<T>\_\_\_\_\_<T>(iter: SetIterable<T>):\_\_\_\_\_<T>\_\_\_\_\_<K, V>(iter: KeyedIterable<K, V>):\_\_\_\_\_<any>\_\_\_\_\_<T>(array: Array<T>):\_\_\_\_\_<T>\_\_\_\_\_<T>(iterator: Iterator<T>):\_\_\_\_\_<T>\_\_\_\_\_<T>(iterable: Object):\_\_\_\_\_<T>
1 construction methods.
List
Create a new immutable List containing the values of the provided iterable-like.
List<T>(): List<T>List<T>(iter: IndexedIterable<T>): List<T>List<T>(iter: SetIterable<T>): List<T>List<K, V>(iter: KeyedIterable<K, V>): List<any>List<T>(array: Array<T>): List<T>List<T>(iterator: Iterator<T>): List<T>List<T>(iterable: Object): List<T>
List
True if the provided value is a List
List.isList(maybeList: any): boolean
2 static methods methods.
List.isList
True if the provided value is a List
List.isList(maybeList: any): boolean
List
Creates a new List containing values
.
List.of<T>(...values: T[]): List<T>
2 static methods methods.
List.of
Creates a new List containing values
.
List.of<T>(...values: T[]): List<T>
List
Returns a new List which includes value
at index
. If index
already exists in this List, it will be replaced.
\_\_\_\_\_(index: number, value: T): List<T>
13 persistent changes methods.
set
Returns a new List which includes value
at index
. If index
already exists in this List, it will be replaced.
set(index: number, value: T): List<T>
List
Returns a new List which excludes this index
and with a size 1 less than this List. Values at indicies above index
are shifted down by 1 to fill the position.
\_\_\_\_\_(index: number): List<T>
13 persistent changes methods.
delete
Returns a new List which excludes this index
and with a size 1 less than this List. Values at indicies above index
are shifted down by 1 to fill the position.
delete(index: number): List<T>
List
Returns a new List with 0 size and no values.
\_\_\_\_\_(): List<T>
13 persistent changes methods.
clear
Returns a new List with 0 size and no values.
clear(): List<T>
List
Returns a new List with the provided values
appended, starting at this List’s size
.
\_\_\_\_\_(...values: T[]): List<T>
13 persistent changes methods.
push
Returns a new List with the provided values
appended, starting at this List’s size
.
push(...values: T[]): List<T>
List
Returns a new List with a size ones less than this List, excluding the last index in this List.
\_\_\_\_\_(): List<T>
13 persistent changes methods.
pop
Returns a new List with a size ones less than this List, excluding the last index in this List.
pop(): List<T>
List
Returns a new List with the provided values
prepended, shifting other values ahead to higher indices.
\_\_\_\_\_(...values: T[]): List<T>
13 persistent changes methods.
unshift
Returns a new List with the provided values
prepended, shifting other values ahead to higher indices.
unshift(...values: T[]): List<T>
List
Returns a new List with a size ones less than this List, excluding the first index in this List, _____ing all other values to a lower index.
\_\_\_\_\_(): List<T>
13 persistent changes methods.
shift
Returns a new List with a size ones less than this List, excluding the first index in this List, shifting all other values to a lower index.
shift(): List<T>
List
Returns a new List with an _____d value at index
with the return value of calling \_\_\_\_\_r
with the existing value, or notSetValue
if index
was not set. If called with a single argument, \_\_\_\_\_r
is called with the List itself.
\_\_\_\_\_(\_\_\_\_\_r: (value: List<T>) => List<T>): List<T>\_\_\_\_\_(index: number,\_\_\_\_\_r: (value: T) => T): List<T>\_\_\_\_\_(index: number, notSetValue: T,\_\_\_\_\_r: (value: T) => T): List<T>
13 persistent changes methods.
update
Returns a new List with an updated value at index
with the return value of calling updater
with the existing value, or notSetValue
if index
was not set. If called with a single argument, updater
is called with the List itself.
update(updater: (value: List<T>) => List<T>): List<T>update(index: number, updater: (value: T) => T): List<T>update(index: number, notSetValue: T, updater: (value: T) => T): List<T>
List\_\_\_\_\_(...iterables: IndexedIterable<T>[]): List<T>\_\_\_\_\_(...iterables: Array<T>[]): List<T>
13 persistent changes methods.
mergemerge(...iterables: IndexedIterable<T>[]): List<T>merge(...iterables: Array<T>[]): List<T>
List
`_____(
merger: (previous?: T, next?: T, key?: number) => T,…iterables: IndexedIterable<T>[]</T>
): List<T>\_\_\_\_\_(
merger: (previous?: T, next?: T, key?: number) => T,...iterables: Array<T>[]</T></T>
): List<T>`</T>
13 persistent changes methods.
mergeWith
`mergeWith(
merger: (previous?: T, next?: T, key?: number) => T,…iterables: IndexedIterable<T>[]</T>
): List<T>mergeWith(
merger: (previous?: T, next?: T, key?: number) => T,...iterables: Array<T>[]</T></T>
): List<T>`</T>
List\_\_\_\_\_(...iterables: IndexedIterable<T>[]): List<T>\_\_\_\_\_(...iterables: Array<T>[]): List<T>
13 persistent changes methods.
mergeDeepmergeDeep(...iterables: IndexedIterable<T>[]): List<T>mergeDeep(...iterables: Array<T>[]): List<T>
List
`_____(
merger: (previous?: T, next?: T, key?: number) => T,…iterables: IndexedIterable<T>[]</T>
): List<T>\_\_\_\_\_(
merger: (previous?: T, next?: T, key?: number) => T,...iterables: Array<T>[]</T></T>
): List<T>`</T>
13 persistent changes methods.
mergeDeepWith
`mergeDeepWith(
merger: (previous?: T, next?: T, key?: number) => T,…iterables: IndexedIterable<T>[]</T>
): List<T>mergeDeepWith(
merger: (previous?: T, next?: T, key?: number) => T,...iterables: Array<T>[]</T></T>
): List<T>`</T>
List
Returns a new List with size size
. If size
is less than this List’s size, the new List will exclude values at the higher indices. If size
is greater than this List’s size, the new List will have undefined values for the newly available indices.
\_\_\_\_\_(size: number): List<T>
13 persistent changes methods.
setSize
Returns a new List with size size
. If size
is less than this List’s size, the new List will exclude values at the higher indices. If size
is greater than this List’s size, the new List will have undefined values for the newly available indices.
setSize(size: number): List<T>
List
Returns a new List having set value
at this keyPath
. If any keys in keyPath
do not exist, a new immutable Map will be created at that key.
\_\_\_\_\_(keyPath: Array<any>, value: any): List<T>\_\_\_\_\_(keyPath: Iterable<any, any>, value: any): List<T>
5 deep persistent changes methods.
setIn
Returns a new List having set value
at this keyPath
. If any keys in keyPath
do not exist, a new immutable Map will be created at that key.
setIn(keyPath: Array<any>, value: any): List<T>setIn(keyPath: Iterable<any, any>, value: any): List<T>
List
Returns a new List having removed the value at this keyPath
. If any keys in keyPath
do not exist, no change will occur.
\_\_\_\_\_(keyPath: Array<any>): List<T>\_\_\_\_\_(keyPath: Iterable<any, any>): List<T>
5 deep persistent changes methods.
deleteIn
Returns a new List having removed the value at this keyPath
. If any keys in keyPath
do not exist, no change will occur.
deleteIn(keyPath: Array<any>): List<T>deleteIn(keyPath: Iterable<any, any>): List<T>
List
`_____(keyPath: Array<any>, updater: (value: any) => any): List<T>\_\_\_\_\_(
keyPath: Array<any>,notSetValue: any,updater: (value: any) => any</any></T></any>
): List<T>\_\_\_\_\_(keyPath: Iterable<any, any>, updater: (value: any) => any): List<T>\_\_\_\_\_(
keyPath: Iterable<any, any>,notSetValue: any,updater: (value: any) => any</T></T>
): List<T>`</T>
5 deep persistent changes methods.
updateIn
`updateIn(keyPath: Array<any>, updater: (value: any) => any): List<T>updateIn(
keyPath: Array<any>,notSetValue: any,updater: (value: any) => any</any></T></any>
): List<T>updateIn(keyPath: Iterable<any, any>, updater: (value: any) => any): List<T>updateIn(
keyPath: Iterable<any, any>,notSetValue: any,updater: (value: any) => any</T></T>
): List<T>`</T>
List
`_____(
keyPath: Iterable<any, any>,…iterables: IndexedIterable<T>[]</T>
): List<T>\_\_\_\_\_(keyPath: Array<any>, ...iterables: IndexedIterable<T>[]): List<T>\_\_\_\_\_(keyPath: Array<any>, ...iterables: Array<T>[]): List<T>`</T></T></any></T></T></any></T>
5 deep persistent changes methods.
mergeIn
`mergeIn(
keyPath: Iterable<any, any>,…iterables: IndexedIterable<T>[]</T>
): List<T>mergeIn(keyPath: Array<any>, ...iterables: IndexedIterable<T>[]): List<T>mergeIn(keyPath: Array<any>, ...iterables: Array<T>[]): List<T>`</T></T></any></T></T></any></T>
List
`_____(
keyPath: Iterable<any, any>,…iterables: IndexedIterable<T>[]</T>
): List<T>\_\_\_\_\_(keyPath: Array<any>, ...iterables: IndexedIterable<T>[]): List<T>\_\_\_\_\_(keyPath: Array<any>, ...iterables: Array<T>[]): List<T>`</T></T></any></T></T></any></T>
5 deep persistent changes methods.
mergeDeepIn
`mergeDeepIn(
keyPath: Iterable<any, any>,…iterables: IndexedIterable<T>[]</T>
): List<T>mergeDeepIn(keyPath: Array<any>, ...iterables: IndexedIterable<T>[]): List<T>mergeDeepIn(keyPath: Array<any>, ...iterables: Array<T>[]): List<T>`</T></T></any></T></T></any></T>
List
Note: Not all methods can be used on a mutable collection or within \_\_\_\_\_
! Only set
, push
, pop
, shift
, unshift
and merge
may be used mutatively.
\_\_\_\_\_(mutator: (mutable: List<T>) => any): List<T>
3 transient changes methods.
withMutations
Note: Not all methods can be used on a mutable collection or within withMutations
! Only set
, push
, pop
, shift
, unshift
and merge
may be used mutatively.
withMutations(mutator: (mutable: List<T>) => any): List<T>
List\_\_\_\_\_(): List<T>
3 transient changes methods.
asMutableasMutable(): List<T>
List\_\_\_\_\_(): List<T>
3 transient changes methods.
asImmutableasImmutable(): List<T>