@lukeboyle/array-item-toggle
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Array Item Toggle

Build Status Coverage Status

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];

/@lukeboyle/array-item-toggle/

    Package Sidebar

    Install

    npm i @lukeboyle/array-item-toggle

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    20.2 kB

    Total Files

    17

    Last publish

    Collaborators

    • lukeboyle