Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yooneskh/initer-map
Wrapper around javascript map to not worry about non set keys
https://github.com/yooneskh/initer-map
Last synced: 19 days ago
JSON representation
Wrapper around javascript map to not worry about non set keys
- Host: GitHub
- URL: https://github.com/yooneskh/initer-map
- Owner: yooneskh
- Created: 2022-04-23T08:33:48.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-04-23T08:45:53.000Z (over 2 years ago)
- Last Synced: 2023-08-08T20:43:39.843Z (over 1 year ago)
- Language: TypeScript
- Size: 1000 Bytes
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Initer Map
This is a very simple wrapper on top of javascript map. It takes an initilizer function from you and returns the value returned from that whenever you try to get an element that isn't set before. Basically, you do not need to handle not set keys using this map.
I originally made this to use it in conjunction with [unified deno lock](https://github.com/yooneskh/unified-deno-lock) as it makes working with that much easier.
## Usage
```typescript
import { IniterMap } from 'https://deno.land/x/initer_map/mod.ts';const map = new IniterMap(() => 5);
const summedNumber = map.get('any-key') + 10; // will be 15
```## Licensce
[MIT](https://opensource.org/licenses/MIT)