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.

88 lines (41 loc) 1.05 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; [arrayPushUnique](./rc-js-util.arraypushunique.md) ## arrayPushUnique() function Like `Array.push` but checks if the value is unique first. **Signature:** ```typescript export declare function arrayPushUnique<TItem>(items: TItem[], itemToPush: TItem, getComparisonValue?: (item: TItem) => unknown): boolean; ``` ## Parameters <table><thead><tr><th> Parameter </th><th> Type </th><th> Description </th></tr></thead> <tbody><tr><td> items </td><td> TItem\[\] </td><td> </td></tr> <tr><td> itemToPush </td><td> TItem </td><td> </td></tr> <tr><td> getComparisonValue </td><td> (item: TItem) =&gt; unknown </td><td> _(Optional)_ </td></tr> </tbody></table> **Returns:** boolean true if an element was pushed. ## Remarks See [arrayPushUnique()](./rc-js-util.arraypushunique.md)<!-- -->.