ECMAScript Map
like class.
It has same API with Map - JavaScript | MDN.
This library is tiny - 1.5kB(gzip).
✈ bundle-size map-like
map-like@1.0.3
env bundle minify gzip
-- 5.73 kB 3.08 kB 1.5 kB
- Not support
Symbol.Iterator
- This means that
MapLike
object is not iterable.
- This means that
- Return
Array
insteadofIterator
object.MapLike#values()
,MapLike#keys()
,MapLike#entries()
return aArray
.
- Not support
toString()
I've created Map-like to avoid Symbol.iterator
.
Because, the transpiled code of Iterator
has a run-time cost at the current moment.
So, MapLike
does not support Iterator
object.
Install with npm:
npm install map-like
const { MapLike } = require("map-like");
const map = new MapLike(["key", "value"]);
const value = map.get("key");
map.set("newKey", "newValue");
ES6 Map like object. See Map - JavaScript | MDN
return map size
Returns: Number
entries [[key, value], [key, value]] value
Returns: Array
get keys
Returns: Array
get values
Returns: Array
Parameters
key
: Any - The key of the element to return from the Map object.
Returns: Any
has value of key
Parameters
key
: Any - The key of the element to return from the Map object.
Returns: boolean
set value for key
Parameters
key
: Any - The key of the element to return from the Map object.value
: Any
Returns: MapLike
delete value for key
Parameters
key
: Any - The key of the element to return from the Map object.
Returns: boolean
clear defined key,value
Returns: MapLike
forEach map
Parameters
handler
: function (value, key, map)thisArg
: [Any]
See Releases page.
Install devDependencies and Run npm test
:
npm i -d && npm test
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
- Fork it!
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
MIT © azu
Test MapLike
with test-case of https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/Map/tests.js.