toggle-in-set
v0.2.2
Published
Add or remove item from Set
Downloads
3
Readme
toggle-in-set
Add or remove item from Set
Install
npm install --save toggle-in-set
Usage
var toggleInSet = require('toggle-in-set');
toggleInSet(new Set([1, 2, 3]), 2)
//=> Set(2) {1, 3}
toggleInSet(new Set([1, 2, 3]), 4)
//=> [1, 2, 3, 4]
//=> Set(4) {1, 2, 3, 4}
API
toggleInSet(set, value)
Returns an Set
with value
if set
is not includes this value
Returns an Set
without value
if set
is includes this value
set
Required
Type: Set
Set with values needs to toggle
value
Required
Type: *
Value to toggle in set
License
MIT © Vladimir Rodkin