[**@bondsports/general**](../README.md) • **Docs**

***

[@bondsports/general](../globals.md) / uniqueBy

# Function: uniqueBy()

> **uniqueBy**\<`T`\>(`array`?, `iteratee`?): `T`[]

Returns an array of unique items by a given key. Direct wrapper to uniqBy from lodash.

## Type Parameters

• **T** = `any`

The type of elements in the array.

## Parameters

• **array?**: `T`[]

The array to inspect.

• **iteratee?**: (`value`) => `unknown` \| keyof `T`

The iteratee invoked per element, or a property name.

## Returns

`T`[]

- Returns the new duplicate free array.

## Examples

```ts
// Using a function iteratee
uniqueBy([2.1, 1.2, 2.3], Math.ceil);
// => [2.1, 1.2]
```

```ts
// Using a property name (shorthand)
uniqueBy([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
// => [{ 'x': 1 }, { 'x': 2 }]
```

## Defined in

[utils/array.util.ts:114](https://github.com/Bond-Sports/bondUtils/blob/545f16ceb055481acfd7641d7809c0f252d3a5e6/packages/general/src/utils/array.util.ts#L114)
