An extension of the Map class with more Array-like features.
There ain't no installation. It's a Deno module.
import { BetterMap } from "https://deno.land/x/bettermap/mod.ts";
new BetterMap<string, unknown>();
class BetterMap<K, V> extends Map<K, V>
Create a new BetterMap
@param {string
} name
- A friendly name for the BetterMap
Convert the map into an array of values
@return Array of items in the map
Array#every but for a Map
@param fn - Function to run on every element.
@return {boolean
}
True or false
Array#filter but for a Map
@param fn - Function to be passed.
@return {BetterMap
}
BetterMap with elements that passed.
@param fn - Function to be passed.
@return A value from the map. If none found, returns undefined.
Get the first element from the map.
@return The first element / undefined.
Get the first element's key from the map.
@return The first element's key / undefined.
Convert the key-value pairs into key-value pairs... I mean a JavaScript object.
@return {Record<string, unknown>
}
Map the Map into an Array.
@param fn - Function for mapping.
@return {T[]
}
Array.
Get a random element from the BetterMap.
@param fn - Function to run on every element.
@return {boolean
}
True or false
Array#reduce but for a Map
@param fn - Reducer function.
@return {T
}
Reduced data.
Array#some but for a Map
@param fn - Function to run on every element.
@return {boolean
}
True or false
Sort elements in the better map.
@param fn - Function to use for sorting.
@return {BetterMap<K, V>
}
sorted BetterMap.
Duplicate of BetterMap#json
@return {Record<string, unknown>
}
Create a new map from an existing Map or an array of key-value pairs.
Do open a new issue or pr regarding bugs or improvements.