I

IMapper<K, V>

An interface for typed dictionary-like implementations.
Inheritance Hierarchy

Remarks

IMapper<K, V>s are most prominently used when working with supplemental configuration for layout algorithms and custom data in GraphML.

Type Parameters

K

The type of element this interface accepts as keys for the mapping.

V

The type of element this interface accepts as values for the mapping.

Members

No filters for this type

Methods

Gets the value for a given key in the mapping.

Setting a value for an already existing key overwrites the previous value.

It depends on the specific implementation of the mapper whether a mapping can be removed. If an implementation provides a way to remove a mapping, that should be preferred over setting a null value. For example, Mapper<K, V> provides the Mapper.delete<K, V> method.

abstract

Parameters

key: K
The key of the mapping.

Return Value

V | null
The value.
Sets the value for a given key in the mapping.

Setting a value for an already existing key overwrites the previous value.

It depends on the specific implementation of the mapper whether a mapping can be removed. If an implementation provides a way to remove a mapping, that should be preferred over setting a null value. For example, Mapper<K, V> provides the Mapper.delete<K, V> method.

abstract

Parameters

key: K
The key of the mapping.
value: V | null
The value.

Static Methods

Creates an IMapper<K, V> instance from the given mapper-like object by performing automatic type conversion.
static

Type Parameters

K

The type of element this interface accepts as keys for the mapping.

V

The type of element this interface accepts as values for the mapping.

Parameters

mapperLike: IMapper<K, V>
conversion
The object to convert to a IMapper<K, V>

Return Value

IMapper<K, V>
An IMapper<K, V> instance, initialized with the values found in mapperLike.
Creates a constant mapper that will always return the constant.
static

Type Parameters

K

The type of the key to use.

V

The type of the value to use.

Parameters

constant: V | null
The constant to return in IMapper<K, V>'s indexer.

Return Value

IMapper<K, V>
A new instance that will always return the same constant.
Create an implementation of IMapper<K, V> that delegates IMapper<K, V> indexer calls to the provided getter and (optional) setter handlers.
The returned implementation silently ignores calls to the IMapper<K, V> indexer setter if no setter has been provided.
static

Type Parameters

K

The type of the key to use.

V

The type of the value to use.

Parameters

getter: function(K): V
The delegate to delegate IMapper<K, V> indexer getter calls to.
Function Details
A delegate that mimics the IMapper.get<K, V> access.
Parameters
key: K
The key of the mapping.
Return Value
V
The value or a suitable default that is associated with key.
setter?: function(K, V): void
The delegate to delegate IMapper<K, V> indexer setter calls to.
Function Details
A delegate that mimics IMapper<K, V>'s indexer write-access.
Parameters
key: K
The key of the mapping.
value: V
The new value of the mapping.

Return Value

IMapper<K, V>
An implementation that delegates to getter and setter.