It implements the logic similar to Array.flat,
handling non-iterable values without throwing errors (unlike spread), and with optional depth support.
However, unlike Array.flat, this operator expands all iterable values, including strings.
If you want to prevent certain values from being expanded, you can pass in second parameter -
skip(value, level) callback function:
Parameter level in the skip callback represents current depth level = 0, ...depth - 1
Note that when handling a synchronous iterable, this operator can only expand synchronous sub-iterables.
But when handling an asynchronous iterable, it can expand mixed sub-iterables, i.e. any combination of
synchronous and asynchronous sub-iterables.
Expands / flattens sub-iterables up to the specified
depth
(default is 1), with support forskip
logic.It implements the logic similar to Array.flat, handling non-iterable values without throwing errors (unlike spread), and with optional
depth
support. However, unlikeArray.flat
, this operator expands all iterable values, including strings. If you want to prevent certain values from being expanded, you can pass in second parameter -skip(value, level)
callback function:Parameter
level
in theskip
callback represents current depth level =0, ...depth - 1
Note that when handling a synchronous iterable, this operator can only expand synchronous sub-iterables. But when handling an asynchronous iterable, it can expand mixed sub-iterables, i.e. any combination of synchronous and asynchronous sub-iterables.
Compare it to a more strict spread operator.