npm

Bring the best of OSS JavaScript development to your projects with npm Orgs - private packages & team management tools.Learn more »

expiry-set

1.0.0 • Public • Published

expiry-set

Build Status Coverage Status

A Set implementation with expirable keys

Install

$ npm install expiry-set

Usage

import ExpirySet from 'expiry-set';
 
const set = new ExpirySet(1000, [
    'unicorn'
]);
 
set.has('unicorn');
//=> true
 
set.add('rainbow');
 
console.log(set.size);
//=> 2
 
// Wait for 1 second...
set.has('unicorn');
//=> false
 
console.log(set.size);
//=> 0

API

ExpirySet(maxAge, [iterable])

maxAge

Type: number

Milliseconds until a key in the Set expires.

iterable

Type: Object

An Array or other iterable object.

Instance

Any of the Set methods.

Related

  • expiry-map - A Map implementation with expirable items

License

MIT © Sam Verschueren

install

npm i expiry-set

Downloadsweekly downloads

3

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability