JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 7245677
  • Score
    100M100P100Q280006F
  • License MIT

A JavaScript Map() or a Similar() object if Map is not available.

Package Exports

  • map-or-similar
  • map-or-similar/src/map-or-similar.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (map-or-similar) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Map Or Similar

A JavaScript Map() or a Similar() object if Map is not available. Supports complex objects for keys. Highly performant. No dependencies. Made for the browser and nodejs.

Install

npm install map-or-similar --save

Use

Supports the following methods and properties identically to Map():

set(key, val): Sets a value to a key. Key can be a complex object, array, etc.
get(key)     : Returns the value of a key.
has(key)     : Returns true if the key exists, otherwise false.
delete(key)  : Deletes a key and its value.
size         : Returns a count of keys-value pairs.
var MapOrSimilar = require('map-or-similar');
var mapOrSimilar = new MapOrSimilar();

mapOrSimilar.set({ prop: 'a complex object as key '}, 'my value'); // sets 'my value' to specified key
mapOrSimilar.get({ prop: 'a complex object as key '}); // returns 'my value'
mapOrSimilar.has({ prop: 'a complex object as key '}); // returns true
mapOrSimilar.size // returns 1
mapOrSimilar.delete({ prop: 'a complex object as key '}); // deletes item

Does not support any other Map methods or properties.

Test

npm run test