# swap

Swaps two elements in an array at the given indices.

## Parameters

- **arr** `T[]` — The source array.
- **options** `SwapOptions` — The indexes of the elements to swap.

## Returns

`T[]` — A new array with swapped elements.

## Example

```js
swap([1, 2, 3, 4, 5], { x: 0, y: 1 }) //=> [2, 1, 3, 4, 5]
```
