Socket
Socket
Sign inDemoInstall

expire-set

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    expire-set

A set which values automatically expire


Version published
Weekly downloads
173
increased by74.75%
Maintainers
1
Install size
17.5 kB
Created
Weekly downloads
 

Readme

Source

expire-set

expire-set is a package that is basically a set - only that its values expire after a certain set time.

Usage

Just use it as if you would be using a normal set:

const ExpireSet = require("expire-set");
const timeout = 10000; // 10 seconds
const set = new ExpireSet(timeout);
set.add("fox");
console.log(set.has("fox")); // outputs true
setTimeout(() => {
	console.log(set.has("fox")); // outputs false
}, timeout + 6); // the library needs some time to do its magic

You can also use it with typescript:

import ExpireSet from "expire-set";
const timeout = 10000; // 10 seconds
const set = new ExpireSet<string>(timeout);
set.add("blah");
set.delete("blah");

Methods

The following methods exist:

  • set.size: Returns the size of the ExpiredSet
  • set.all: Returns the ExpiredSet as a normal Set
  • set.add(value): Adds a value to the ExpiredSet, returning itself
  • set.has(value): Returns true/false, if the ExpiredSet has the value
  • set.delete(value): Deletes a value of the ExpiredSet, returning itself

FAQs

Last updated on 27 Mar 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc