https://github.com/vovanr/toggle-in-set
Add or remove item from Set
https://github.com/vovanr/toggle-in-set
Last synced: 3 months ago
JSON representation
Add or remove item from Set
- Host: GitHub
- URL: https://github.com/vovanr/toggle-in-set
- Owner: VovanR
- License: mit
- Created: 2020-06-10T12:10:06.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-07-13T11:13:38.000Z (about 3 years ago)
- Last Synced: 2025-03-18T14:58:35.386Z (over 1 year ago)
- Language: JavaScript
- Size: 730 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# toggle-in-set
[![Commitizen friendly][commitizen-image]][commitizen-url]
[![XO code style][codestyle-image]][codestyle-url]
[![NPM version][npm-image]][npm-url]
[![Build Status][build-image]][build-url]
[![Coveralls Status][coveralls-image]][coveralls-url]
> Add or remove item from Set
## Install
```shell
npm install --save toggle-in-set
```
## Usage
```js
var toggleInSet = require('toggle-in-set');
toggleInSet(new Set([1, 2, 3]), 2);
//=> Set(2) {1, 3}
toggleInSet(new Set([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](https://github.com/VovanR)
[commitizen-url]: https://commitizen.github.io/cz-cli/
[commitizen-image]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square
[codestyle-url]: https://github.com/xojs/xo
[codestyle-image]: https://img.shields.io/badge/code_style-XO-5ed9c7.svg?style=flat-square
[npm-url]: https://npmjs.org/package/toggle-in-set
[npm-image]: https://img.shields.io/npm/v/toggle-in-set.svg?style=flat-square
[build-url]: https://github.com/VovanR/toggle-in-set/actions/workflows/test-workflow.yml
[build-image]: https://img.shields.io/github/actions/workflow/status/vovanr/toggle-in-set/test-workflow.yml?branch=master&style=flat-square
[coveralls-url]: https://coveralls.io/r/VovanR/toggle-in-set
[coveralls-image]: https://img.shields.io/coveralls/VovanR/toggle-in-set.svg?style=flat-square