https://github.com/binki/maputil
Simple utilities for ES6 Map.
https://github.com/binki/maputil
Last synced: 12 months ago
JSON representation
Simple utilities for ES6 Map.
- Host: GitHub
- URL: https://github.com/binki/maputil
- Owner: binki
- License: mit
- Created: 2017-06-25T17:30:57.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-25T20:40:17.000Z (almost 9 years ago)
- Last Synced: 2025-05-27T01:02:05.609Z (about 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Some utilities for `Map`. So far, there are very few. Please open
issues with rationale to propose new additions.
## `getOrSet(map, key, createValue)`
If `key` exists in `map`, return the value. Otherwise, set it to the
value returned by `createValue()` and return the newly added value.
The ES6 `Map` [does not provide a DRY way to get or set a
value](https://stackoverflow.com/a/44733792/429091). This function
does that.