map like - nberlette/is GitHub Wiki
function isMapLike<K, V>(it: unknown): it is MapLike<K, V>;
Checks whether a given value is a
MapLike
object.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a MapLike
object; otherwise, false
.
function isMapLikeConstructor(it: unknown): it is MapLikeConstructor;
Checks whether a given value is a
MapLikeConstructor
function, which is defined as a constructor function with a prototype
property
that appears to be a MapLike
object.
Name | Info |
---|---|
it |
The value to check. |
true
if the value is a
MapLikeConstructor
;
otherwise, false
.
Guards
Map-like objects are collections of keys and values, where each key may only appear once in the collection.
Types
K
V
readonly size: number;
Gets the number of elements in the collection.
readonly [Symbol.toStringTag]: string;
has(key: K): boolean;
Tests whether a key is present in the collection.
Name | Info |
---|---|
key |
The key to lookup. |
true
if the key is present in the collection; otherwise, false
.
get(key: K): V | undefined;
Gets the value associated with the provided key, if it exists.
Name | Info |
---|---|
key |
The key to lookup. |
The value associated with the provided key, or undefined
.
set(key: K, value: V): this;
Sets the value in the collection associated with the provided key.
Name | Info |
---|---|
key |
The key to set. |
value |
The value to set. |
The collection.
clear(): void;
Removes all entries from the collection.
delete(key: K): boolean;
Removes a key from the collection.
Name | Info |
---|---|
key |
The key to remove. |
true
if the delete operation was successful, otherwise false
.
keys(): IterableIterator<K>;
Returns an IterableIterator
for the keys present in the collection.
values(): IterableIterator<V>;
Returns an IterableIterator
for the values present in the collection.
entries(): IterableIterator<
[K, V]
>;
Returns an IterableIterator
for the entries present in the collection. Each
entry is a tuple containing the key and value for each element.
forEach<This = void>(
cb: (this: This, value: V, key: K, map: MapLike<K, V>) => void,
thisArg?: This,
): void;
Executes a provided function once per each key/value pair in the collection.
Name | Info |
---|---|
cb |
The callback to execute. |
thisArg |
The value to use as this when executing the callback. |
Nothing.
[Symbol.iterator](): IterableIterator<
[K, V]
>;
Returns an IterableIterator
for the entries present in the collection.
A constructor function for creating new MapLike
objects.
Types
readonly prototype: MapLike<unknown, unknown>;