UNPKG

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
<!-- Do not edit this file. It is automatically generated by API Documenter. --> [Home](./index.md) &gt; [rc-js-util](./rc-js-util.md) &gt; [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)<!-- -->&lt;TKey, TItem&gt; </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) =&gt; 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)<!-- -->.