Writing code

CLASS

EntryList

@skmtc/lang-typescript 0.19.1

Utility class for working with arrays of key-value pair entries.

Provides methods for transforming entry arrays into objects and lists with custom mapping functions.

Signature

import { EntryList } from '@skmtc/lang-typescript'

class EntryList<T extends Stringable>
T

Type of the entry values

Constructor

constructor

constructor(entries: Entry<T>[])

Creates a new EntryList instance.

entries

Array of key-value pair entries to work with

Properties

entries, Entry<T>[]

Array of key-value pair entries

Methods

toObject

toObject<V extends Stringable>(mapFn: EntryMapFn<T, V>): ListObject<V>

Transforms entries into an object using a mapping function.

mapFn

Function to transform each entry into a value

Returns

Object with transformed values

toLines

toLines<V extends Stringable>(mapFn: EntryMapFn<T, V>): ListLines<V>

Transforms entries into a List using a mapping function.

mapFn

Function to transform each entry into a value

Returns

List containing the transformed values

toArray

toArray<V extends Stringable>(mapFn: EntryMapFn<T, V>): ListArray<V>

Transforms entries into an array using a mapping function.

mapFn

Function to transform each entry into a value

Returns

Array containing the transformed values