Skip to content

3stacks/array-item-toggle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Utility function to check for the presence of an item in array and either remove or add it.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published