0.2.0 • Published 7 years ago
map-better v0.2.0
map-better
Map with better functions
Install
npm i map-betterUsage
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)Invertskeys<==>valuesof the Map.entriesArray()Returns Array.from(this.entries()).valuesArray()Returns Array.from(this.values()).keysArray()Returns Array.from(this.keys()).lengthReturns this.sizeMap.from(array, (key) => value)Create a new Map using keys from an array and values from the callback