Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

expiring_map

Tyler-Murphy10ISC1.0.1

An extension to es6 Maps that allows for map-level and key-level expiration times

map, es6, expire, expiration, timeout, time, limit

readme

Build Status

Install

npm install --save expiring_map

Use

Provide an expiration time, in milliseconds, to the constructor. Expiration times can also be provided for each set call. If there's no expiration time, the entry will never expire.

const ExpiringMap = require('expiring_map').ExpiringMap

let map = new ExpiringMap(3000)
map.set(1, 1)  // will expire after 3 seconds
map.set(2, 2, 1000)  // will expire after 1 second

let map2 = new ExpiringMap()
map2.set(1, 1)  // will never expire