set
/
2.2.1
set 2.2.1
Install from the command line:
Learn more about npm packages
$ npm install @supercharge/set@2.2.1
Install via package.json:
"@supercharge/set": "2.2.1"
About this version
An Array-aligned Set
class and the one JavaScript should have shipped
Installation · Docs · Usage
Follow @marcuspoehls and @superchargejs for updates!
The @supercharge/set
package provides an improved Set
implementation.
- aligned with the
Array
class instead ofMap
- provides helpful methods like
.map(callback)
,.filter(callback)
,.find(callback)
,.isEmpty()
, and many more. - compares values for
deep equality
and notreference
- it’s the
Set
class JavaScript should have shipped
npm i @supercharge/set
Using @supercharge/set
is pretty straightforward. The package exports a Set
class providing all methods to interact with the set.
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' }
Do you miss a function? We very much appreciate your contribution! Please send in a pull request 😊
- Create a fork
- Create your feature branch:
git checkout -b my-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request 🚀
MIT © Supercharge
superchargejs.com · GitHub @supercharge · Twitter @superchargejs