yooneskh / initer-map

Wrapper around javascript map to not worry about non set keys

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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 as it makes working with that much easier.

Usage

import { IniterMap } from 'https://deno.land/x/initer_map/mod.ts';


const map = new IniterMap<string, number>(() => 5);

const summedNumber = map.get('any-key') + 10; // will be 15

Licensce

MIT

About

Wrapper around javascript map to not worry about non set keys


Languages

Language:TypeScript 100.0%