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.
100 lines (46 loc) • 1.35 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [rc-js-util](./rc-js-util.md) > [dictionaryCollect](./rc-js-util.dictionarycollect.md)
## dictionaryCollect() function
Like `Array.reduce` but for dictionaries and without the requirement to return the value in the callback.
**Signature:**
```typescript
export declare function dictionaryCollect<TRet, TKey extends string | number | symbol, TItem>(items: TProperty<TKey, TItem>, collected: TRet, collect: (collected: TRet, item: TItem, key: TKey, index: number) => void, keys?: readonly TKey[]): TRet;
```
## Parameters
<table><thead><tr><th>
Parameter
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
items
</td><td>
[TProperty](./rc-js-util.tproperty.md)<!-- --><TKey, TItem>
</td><td>
</td></tr>
<tr><td>
collected
</td><td>
TRet
</td><td>
</td></tr>
<tr><td>
collect
</td><td>
(collected: TRet, item: TItem, key: TKey, index: number) => void
</td><td>
</td></tr>
<tr><td>
keys
</td><td>
readonly TKey\[\]
</td><td>
_(Optional)_
</td></tr>
</tbody></table>
**Returns:**
TRet
## Remarks
See [dictionaryCollect()](./rc-js-util.dictionarycollect.md)<!-- -->.