Flattens an input sync iterable up to a specified depth. Returns a new synchronous iterable.
A function that accepts an input sync iterable and returns a new synchronous iterable.
const input = [1, [2, 3], [4, [5]]];const flatSyncIterable = flatSync<number>(1)(input);for (const x of flatSyncIterable) { console.log(x); // Logs 1, 2, 3, 4, [5]}
Available as flat when imported from peter-piper/sync.
flat
peter-piper/sync
The type of elements in the input sync iterable.
The depth of flattening.
Optional
The depth of flattening, defaults to 1.
Generated using TypeDoc
Flattens an input sync iterable up to a specified depth. Returns a new synchronous iterable.
Returns
A function that accepts an input sync iterable and returns a new synchronous iterable.
Example
Remarks
Available as
flat
when imported frompeter-piper/sync
.