Skip to content

@ralphschuler.better map.BetterMap

github-actions edited this page Nov 26, 2023 · 14 revisions

Class: BetterMap<k, v>

@ralphschuler/better-map.BetterMap

A better Map class that has some more useful methods.

Type parameters

Name Description
k The type of the keys.
v The type of the values.

Hierarchy

  • Map<k, v>

    BetterMap

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new BetterMap<k, v>(entries?): BetterMap<k, v>

Type parameters

Name
k
v

Parameters

Name Type
entries? null | readonly readonly [k, v][]

Returns

BetterMap<k, v>

Inherited from

Map<k, v>.constructor

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:50

new BetterMap<k, v>(iterable?): BetterMap<k, v>

Type parameters

Name
k
v

Parameters

Name Type
iterable? null | Iterable<readonly [k, v]>

Returns

BetterMap<k, v>

Inherited from

Map<k, v>.constructor

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:159

Properties

[toStringTag]

Readonly [toStringTag]: string

Inherited from

Map.[toStringTag]

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:137


size

Readonly size: number

Inherited from

Map.size

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:45


[species]

Static Readonly [species]: MapConstructor

Inherited from

Map.[species]

Defined in

node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts:319

Methods

[iterator]

[iterator](): IterableIterator<[k, v]>

Returns an iterable of entries in the map.

Returns

IterableIterator<[k, v]>

Inherited from

Map.[iterator]

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:119


clear

clear(): void

Returns

void

Inherited from

Map.clear

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:20


delete

delete(key): boolean

Parameters

Name Type
key k

Returns

boolean

true if an element in the Map existed and has been removed, or false if the element does not exist.

Inherited from

Map.delete

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:24


entries

entries(): IterableIterator<[k, v]>

Returns an iterable of key, value pairs for every entry in the map.

Returns

IterableIterator<[k, v]>

Inherited from

Map.entries

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:124


filter

filter(predicate): BetterMap<k, v>

Filters the map by a predicate.

Parameters

Name Type Description
predicate (v: v, k: k) => boolean The predicate to filter by.

Returns

BetterMap<k, v>

A new map with the filtered values.

Defined in

packages/better-map/src/index.ts:26


forEach

forEach(callbackfn, thisArg?): void

Executes a provided function once per each key/value pair in the Map, in insertion order.

Parameters

Name Type
callbackfn (value: v, key: k, map: Map<k, v>) => void
thisArg? any

Returns

void

Inherited from

Map.forEach

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:28


get

get(key): undefined | v

Returns a specified element from the Map object. If the value that is associated to the provided key is an object, then you will get a reference to that object and any change made to that object will effectively modify it inside the Map.

Parameters

Name Type
key k

Returns

undefined | v

Returns the element associated with the specified key. If no element is associated with the specified key, undefined is returned.

Inherited from

Map.get

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:33


has

has(key): boolean

Parameters

Name Type
key k

Returns

boolean

boolean indicating whether an element with the specified key exists or not.

Inherited from

Map.has

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:37


keys

keys(): IterableIterator<k>

Returns an iterable of keys in the map

Returns

IterableIterator<k>

Inherited from

Map.keys

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:129


merge

merge(map, resolve?): void

Maps the map by a predicate.

Parameters

Name Type
map Map<k, v>
resolve (k: k, a: v, b: v) => v

Returns

void

A new map with the mapped values.

Defined in

packages/better-map/src/index.ts:40


set

set(key, value): BetterMap<k, v>

Adds a new element with a specified key and value to the Map. If an element with the same key already exists, the element will be updated.

Parameters

Name Type
key k
value v

Returns

BetterMap<k, v>

Inherited from

Map.set

Defined in

node_modules/typescript/lib/lib.es2015.collection.d.ts:41


update

update(key, updater, notset?): void

Updates a value in the map if it exists, otherwise sets it to the default value.

Parameters

Name Type Description
key k The key of the value to update.
updater (v: v, k: k) => v The function to update the value with.
notset? v The default value to set if the key does not exist.

Returns

void

Defined in

packages/better-map/src/index.ts:16


values

values(): IterableIterator<v>

Returns an iterable of values in the map

Returns

IterableIterator<v>

Inherited from

Map.values

Defined in

node_modules/typescript/lib/lib.es2015.iterable.d.ts:134

Typescript Libraries

Modules

Namespaces

Clone this wiki locally