1.0.1 • Published 1 year ago

fixedsize-map-x v1.0.1

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

About

Fixed Size Map is a Javascript implementation of Map to hold a limited number of keys

Advantages

  • Simple to use cache
  • Lightweight

Installation

npm i fixedsize-map-x

Usage

const FixedSizeMap = require("fixedsize-map-x");

const cache = new FixedSizeMap(100);

// Adding elements to cache
cache.add("k1", "Some Value");
cache.add("k2", "Some Value");

Available Methods

MethodDescription
add(k, v)Adds a key and pairs it with a value
contains(k)Checks if this cache contains a key
get(k)Retrieves a value from this cache corresponding to the specified key
remove(k)Removed the key value entry from this cache corresponding to the specified key
clear()Empty the cache map