@supercharge/set
TypeScript icon, indicating that this package has built-in type declarations

2.2.1 • Public • Published


Set

An Array-aligned Set class and the one JavaScript should have shipped


Installation · Docs · Usage



Latest Version Monthly downloads

Follow @marcuspoehls and @superchargejs for updates!


Introduction

The @supercharge/set package provides an improved 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

Quick Usage Overview

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' }

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


superchargejs.com  ·  GitHub @supercharge  ·  Twitter @superchargejs

Package Sidebar

Install

npm i @supercharge/set

Weekly Downloads

2

Version

2.2.1

License

MIT

Unpacked Size

30.5 kB

Total Files

11

Last publish

Collaborators

  • marcuspoehls
  • peitek
  • celsiusf