Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mheiber/toggle-member
`toggleMember(set, member)` returns a new set with/without `member`.
https://github.com/mheiber/toggle-member
Last synced: 21 days ago
JSON representation
`toggleMember(set, member)` returns a new set with/without `member`.
- Host: GitHub
- URL: https://github.com/mheiber/toggle-member
- Owner: mheiber
- Created: 2016-08-27T17:00:04.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2016-08-28T02:06:52.000Z (over 8 years ago)
- Last Synced: 2024-04-26T14:06:03.376Z (8 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# toggle-member
`toggleMember(set, member)` returns a new set with/without `member`.
```js
const toggleMember = require('toggle-member')
const setWithFoo = new Set(['foo', 'bar'])
toggleMember(setWithFoo, 'foo') // Set(['bar'])
toggleMember(setWithFoo, 'baz') // Set(['foo', 'bar', 'baz'])// or use with chill-patch to safely monkey patch Set
const chillPatch = require('chill-patch')
const toggle = chillPatch(Set, toggleMember)
setWithFoo[toggle]('foo') // Set(['bar'])
```Requires ES2015 `Set`:
- See [browser compatibility](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set#Browser_compatibility).
- Or include [ES6 Shim](https://github.com/paulmillr/es6-shim).