https://github.com/supercharge/set
An Array-aligned Set class and the one JavaScript should have shipped
https://github.com/supercharge/set
class hacktoberfest hacktoberfest2021 javascript set supercharge
Last synced: about 1 month ago
JSON representation
An Array-aligned Set class and the one JavaScript should have shipped
- Host: GitHub
- URL: https://github.com/supercharge/set
- Owner: supercharge
- License: mit
- Created: 2020-07-17T12:14:10.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-02-04T04:39:03.000Z (over 1 year ago)
- Last Synced: 2025-08-08T22:50:55.294Z (2 months ago)
- Topics: class, hacktoberfest, hacktoberfest2021, javascript, set, supercharge
- Language: TypeScript
- Homepage: https://superchargejs.com/docs/set
- Size: 110 KB
- Stars: 7
- Watchers: 1
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Set
An Array-alignedSet
class and the one JavaScript should have shipped
Installation ·
Docs ·
Usage
Follow @marcuspoehls and @superchargejs for updates!
---
## Introduction
The `@supercharge/set` package provides an improved [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) implementation.- aligned with the `Array` class instead of `Map`
- provides helpful methods like `.map(callback)`, `.filter(callback)`, `.find(callback)`, `.isEmpty()`, and many more.
- compares values for `deep equality` and not `reference`
- it’s the `Set` class JavaScript should have shipped## Installation
```
npm i @supercharge/set
```## Resources
- [Documentation](https://superchargejs.com/docs/set)
## Quick Usage Overview
Using `@supercharge/set` is pretty straightforward. The package exports a `Set` class providing all methods to interact with the set.```js
const Set = require('@supercharge/set')const users = new Set()
users.isEmpty() // true
users
.add({ id: 1, name: 'Marcus' })
.add({ id: 2, name: 'Norman' })
.add({ id: 3, name: 'Christian' })users.isNotEmpty() // true
const usernames = users.map(user => {
return user.name
})
// [ 'Marcus', 'Norman', 'Christian' ]const marcus = users.find(user => {
return user.name === 'Marcus'
})
// { id: 1, name: 'Marcus' }
```## Contributing
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊1. Create a fork
2. Create your feature branch: `git checkout -b my-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request 🚀## License
MIT © [Supercharge](https://superchargejs.com)---
> [superchargejs.com](https://superchargejs.com) ·
> GitHub [@supercharge](https://github.com/supercharge) ·
> Twitter [@superchargejs](https://twitter.com/superchargejs)