1.0.2 • Published 5 years ago
@lukeboyle/array-item-toggle v1.0.2
Array Item Toggle
A helper function to check if an item is:
- in an array -> remove it from the array,
- not in the array -> add it to the array
Usage
import toggle from 'array-item-toggle';
toggle([1, 2, 3], 1)
// returns a new array = [2, 3];
toggle([2, 3], 1)
// returns a new array = [2, 3, 1];