rc-js-util
Version:
A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.
76 lines (36 loc) • 1.31 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [rc-js-util](./rc-js-util.md) > [arrayFlatMap](./rc-js-util.arrayflatmap.md)
## arrayFlatMap() function
Iterate over `ArrayLike` calling a callback against it, the callback returns `ArrayLike` which is concatenated into a single `Array`<!-- -->.
**Signature:**
```typescript
export declare function arrayFlatMap<TItem, TTransformed>(items: ArrayLike<TItem>, mapCallback: (item: TItem, index: number) => ArrayLike<TTransformed> | null): TTransformed[];
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
items
</td><td>
ArrayLike<TItem>
</td><td>
The items to iterate over.
</td></tr>
<tr><td>
mapCallback
</td><td>
(item: TItem, index: number) => ArrayLike<TTransformed> \| null
</td><td>
The return from this callback is concatenated to the result, unless null is returned in which case the result is omitted.
</td></tr>
</tbody></table>
**Returns:**
TTransformed\[\]
The output of `mapCallback` flattened into a single array.
## Remarks
See [arrayFlatMap()](./rc-js-util.arrayflatmap.md)<!-- -->.