https://github.com/supercharge/map
An extended Map class and the one JavaScript should have shipped
https://github.com/supercharge/map
class hacktoberfest javascript map supercharge
Last synced: 4 months ago
JSON representation
An extended Map class and the one JavaScript should have shipped
- Host: GitHub
- URL: https://github.com/supercharge/map
- Owner: supercharge
- License: mit
- Created: 2020-07-17T10:14:58.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2022-05-18T12:29:10.000Z (over 3 years ago)
- Last Synced: 2025-05-24T03:07:31.319Z (5 months ago)
- Topics: class, hacktoberfest, javascript, map, supercharge
- Language: TypeScript
- Homepage:
- Size: 67.4 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
![]()
Map
An extendedMap
and the one JavaScript should have shipped
Installation ·
Docs ·
Usage
Follow @marcuspoehls and @superchargejs for updates!
---
## Introduction
The `@supercharge/map` package provides an extended JavaScript `Map` class. It comes with additional methods like `.isEmpty()` or `.map(callback)`.You already know methods like `.map()` from arrays and having them available on maps improves your development experience and makes your code more readable.
## Installation
```
npm i @supercharge/map
```## Docs
Find all the [details for `@supercharge/map` in the extensive Supercharge docs](https://superchargejs.com/docs/map).## Usage
Using `@supercharge/map` is pretty straightforward. Import the `Map` class exported from the `@supercharge/map` package and use it (almost) the same way you would use JavaScript’s `Map` class. This package gives you the parameter order `key, value, map` in callbacks. JavaScript’s Map class gives you `value, key, map`:```js
const Map = require('@supercharge/map')const cache = new Map()
cache.isEmpty()
// truecache
.set('user:1', 'Marcus')
.set('user:2', 'Supercharge')cache.isNotEmpty()
// trueconst users = cache.map((key, value, map) => {
return { [key]: value }
})// [{ 'user:1': 'Marcus' }, { 'user:2': 'Supercharge' }]
```
## 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)