Socket
Socket
Sign inDemoInstall

expiry-map

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expiry-map

A Map implementation with expirable items


Version published
Weekly downloads
61K
increased by0.91%
Maintainers
1
Weekly downloads
 
Created
Source

expiry-map

CI codedov

A Map implementation with expirable items

Memory is automatically released when an item expires by removing it from the Map.

Install

$ npm install expiry-map

Usage

import ExpiryMap = require('expiry-map');

const map = new ExpiryMap(1000, [
	['unicorn', '🦄']
]);

map.get('unicorn');
//=> 🦄

map.set('rainbow', '🌈');

console.log(map.size);
//=> 2

// Wait for 1 second...
map.get('unicorn');
//=> undefined

console.log(map.size);
//=> 0

API

ExpiryMap(maxAge, [iterable])

maxAge

Type: number

Milliseconds until an item in the Map expires.

iterable

Type: Object

An Array or other iterable object whose elements are key-value pairs.

Instance

Any of the Map methods.

  • expiry-set - A Set implementation with expirable keys
  • map-age-cleaner - Automatically cleanup expired items in a Map

License

MIT © Sam Verschueren

Keywords

FAQs

Package last updated on 08 Feb 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc