map-better

0.2.0 • Public • Published

map-better

Map with better functions

Install

npm i map-better

Usage

const Map = require('map-better')

API

  • .getKey(value) Returns the key of the specified element
  • .hasValue(value) Returns a boolean indicating whether the element (at any key) exists or not
  • .setKey(value, key) Updates the key of the specified element (or throws an error if element doesn't exist)
  • .map((value, key) => newValue) Creates a new Map with same keys but with values from the result of the callback
  • .mapKeys((key, value) => newKey)    〃   a new Map with same values but with keys from the result of the callback
  • .mapArray((value, key) => newValue) Creates a new array with the results of the callback
  • .filter((value, key) => true|false) Creates a (new) filtered Map (with the same keys)
  • .find((value) => true|false) Returns first element (value) that satisfies the testing function
  • .reverse(inPlace = false) Reverses the (iterator of the) Map
  • .invert(inPlace = false) Inverts keys <==> values of the Map
  • .entriesArray() Returns Array.from(this.entries())
  • .valuesArray() Returns Array.from(this.values())
  • .keysArray() Returns Array.from(this.keys())
  • .length Returns this.size
  • Map.from(array, (key) => value) Create a new Map using keys from an array and values from the callback

Readme

Keywords

none

Package Sidebar

Install

npm i map-better

Weekly Downloads

1

Version

0.2.0

License

none

Unpacked Size

6.3 kB

Total Files

4

Last publish

Collaborators

  • laggingreflex