npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@es-node/ts-map-storage

v1.0.2

Published

A simple memory manager for standardizing the behavior when interacting with JavaScript Map Object as a memory storage.

Readme

ts-map-storage

This ts-map-storage is a simple storage management module for standardizing behavior when interacting with Map Object as a in-memory-storage, written in typescript.

The basic features limiting the items in storage, cleaning up expired key in interval, deleting the lru (least recently used) key when the item count limit is hit

Installation

npm install @es-node/ts-map-storage

Usage

import { StorageManager } from '@es-node/ts-map-storage';

// Create a new instance of StorageManager
const storage = new StorageManager({
    maxItems: 100, // Maximum number of items allowed in the storage (optional)
    expireMs: 3600000, // Expiration time in milliseconds for items in the storage (optional)
    keyLength: 12, // Length of keys used for storage items (optional)
    cleanupIntervalMs: 86400000, // Interval in milliseconds for automatic cleanup (optional)
});

// Add an entry to the storage
storage.add({ key: 'key1', value: 'value1' });

// Get the value of an entry from the storage
const item = storage.get('key1');
console.log(item); // { value: 'value1', expireAt: [expiration date], updateAt: [last update date] }

// Delete an entry from the storage
storage.delete('key1');

// Clear all entries from the storage
storage.clear();

API

The StorageManager module provides the following methods and properties:

Constructor

new StorageManager(config: IConfig) Creates a new instance of StorageManager with the specified configuration options.

The config object can have the following properties:

  • maxItems (optional): Maximum number of items allowed in the storage.
  • expireMs (optional): Expiration time in milliseconds for items in the storage.
  • keyLength (optional): Length of keys used for storage items.
  • cleanupIntervalMs (optional): Interval in milliseconds for automatic cleanup.

Methods

add(entry: { key: string; value: V }): TStorageResult<V> Adds an entry to the storage.

Returns a storage result object indicating the success or failure of the operation.

update(entry: { key: string; value: V }): TStorageResult<V> Updates an existing entry in the storage.

Returns a storage result object indicating the success or failure of the operation.

upsert(entry: { key: string; value: V }): TStorageResult<V> Adds or updates an entry in the storage.

Returns a storage result object indicating the success or failure of the operation.

get(key: string): TStorageValue<V> | undefined Retrieves the value of an entry in the storage based on the provided key.

Returns the value and metadata of the retrieved entry, or undefined if the key does not exist.

delete(key: string): boolean Deletes an entry from the storage based on the provided key.

Returns a boolean indicating whether the deletion was successful (true) or the key did not exist (false).

clear(): void Clears all entries from the storage.

stopCleanup(): void Stops the automatic cleanup process by clearing the cleanup interval.

getUniqueKey(): string Generates a unique key for storage, ensuring it does not already exist in the storage.

Returns a unique key.

Properties

maxItems: number The maximum number of items allowed in the storage. This property is read-only.

expireMs: number The expiration time in milliseconds for items in the storage. This property is read-only.

size: number The current size of the storage. It represents the number of items currently stored in the storage. This property is read-only.

Types

The StorageManager module defines several types to support its functionality:

TStorageValue<V> A type representing the value stored in the storage. If the value is an object, it includes additional properties for expiration and update timestamps. If the value is not an object, it includes the value, expireAt, and updateAt properties.

TStorageResult<V> A type representing the result of storage operations. It can be either a success result, including the stored value and metadata, or a failure result.

IConfig An interface representing the configuration options for the StorageManager constructor. It includes optional properties for maxItems, expireMs, keyLength, and cleanupIntervalMs.

I hope this provides you with the necessary information about the StorageManager module. Let me know if you have any further questions!