Socket
Socket
Sign inDemoInstall

@supercharge/map

Package Overview
Dependencies
0
Maintainers
3
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @supercharge/map

An extended Map class and the one JavaScript should have shipped


Version published
Weekly downloads
5
increased by25%
Maintainers
3
Install size
18.4 kB
Created
Weekly downloads
 

Changelog

Source

1.5.0 - 2021-09-13

Added

  • add toArray() method: converting the map to a JavaScript array containing arrays for each key-value-pair of this map
  • Map.from() method to create a new Map instance. This Map.from method aligns with JavaScript’s Array.from or Object.fromX methods
  • add pick(...keys) method: creating a new map with the picked keys

Updated

  • bump dependencies
  • use uvu and c8 instead of jest for testing

Readme

Source


Map

An extended Map and the one JavaScript should have shipped


Installation · Docs · Usage



Latest Version Monthly downloads

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.

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:

const Map = require('@supercharge/map')

const cache = new Map()

cache.isEmpty()
// true

cache
  .set('user:1', 'Marcus')
  .set('user:2', 'Supercharge')

cache.isNotEmpty()
// true

const 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


superchargejs.com  ·  GitHub @supercharge  ·  Twitter @superchargejs

Keywords

FAQs

Last updated on 13 Sep 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc