Skip to content

unctionjs/sequence

Repository files navigation

@unction/sequence

Tests Stability Dependencies

Array<MapperFunctionType<A, B>> | Set<MapperFunctionType<A, B>> | Record<string | number | symbol, MapperFunctionType<A, B>> | Map<unknown, MapperFunctionType<A, B>> => A => Array | Set | Record<string | number | symbol, unknown> | Map<B, unknown> | string Array<MapperFunctionType<A, B>> => A => Array Set<MapperFunctionType<A, B>> => A => Set ObjectType<unknown, MapperFunctionType<A, B>> => A => ObjectType<unknown, B> Map<unknown, MapperFunctionType<A, B>> => A => Map<unknown, B>

Takes a list of functions, a value, and applies that value to each function, returning an array of results.

sequence([increment, decrement])(1) // [2, 0]
sequence(new Set([increment, decrement]))(1) // {2 0}
sequence(new Map([["a", increment], ["b", decrement]]))(1) // {{"a" 2}, {"b" 0}}
sequence({x: increment, y: decrement, z: itself})(1) // {x: 2, y: 0, z: 1}