Skip to content

mapJoin

Overload 1

Map a Map to an array using a mapper and place a joiner between each element. Defaults to joining with a newline.

import { mapJoin } from "@alloy-js/core";
function mapJoin<T, U, V>(src: () => Map<T, U>, cb: (key: T, value: U, index: number) => V, options?: JoinOptions): () => (V | string | undefined | CustomContext)[];

Parameters

src

() => Map<T, U>

cb

(key: T, value: U, index: number) => V

optionsoptional

JoinOptions

Options

enderoptionalChildren

When true, the joiner is placed at the end of the array. When a string, that string is placed at the end of the array. The ender is only emitted when the array has at least one element.

joineroptionalChildren

The string to place between each element.

skipFalsyoptionalboolean

When true, falsy values with the exception of 0 are skipped.

Returns

() => (V | string | undefined | CustomContext)[] The mapped and joined array.

See also

  • join for joining without mapping.

Overload 2

Map a array or iterator to another array using a mapper and place a joiner between each element. Defaults to joining with a newline.

import { mapJoin } from "@alloy-js/core";
function mapJoin<T, V>(src: () => T[] | IterableIterator<T>, cb: (value: T, index: number) => V, options?: JoinOptions): () => (V | string | undefined | CustomContext)[];

Parameters

src

() => T[] | IterableIterator<T>

cb

(value: T, index: number) => V

optionsoptional

JoinOptions

Options

enderoptionalChildren

When true, the joiner is placed at the end of the array. When a string, that string is placed at the end of the array. The ender is only emitted when the array has at least one element.

joineroptionalChildren

The string to place between each element.

skipFalsyoptionalboolean

When true, falsy values with the exception of 0 are skipped.

Returns

() => (V | string | undefined | CustomContext)[] The mapped and joined array.

See also

  • join for joining without mapping.