New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

expiration

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expiration

Expire an entry after a given amount of time

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
Created
Source

Expiration

For having an array of items that expire after a dynamic amount of time

Install:

npm install expiration

Quick Example:

const ExpireList = require('expiration')

const expireList = new ExpireList()

// Expire in 10s
expireList.add('hey!', 10000)

// Expire in 60s
expireList.add('bye!')

console.log(expireList.length) // 2

console.log(expireList.list) // [ 'hey!', 'bye!']

...

// 30s later

console.log(expireList.length) // 1

console.log(expireList.list) // [ 'bye!' ]

...

// 60s later

console.log(expireList.length) // 0

console.log(expireList.list) // []

Methods

constructor()

Creates a new expiring list

add(storeItem, timeToCache = 60000)

Adds the given item to the list and removes from the list in the given amount of milliseconds

Parameters:
  • storeItem - Object to store (can be a string, number, item, whatever)
  • timeToCache - Amount of milliseconds to store

length

How long is the list

list

What is the list at the given time

Notes:

Full example can be found under test/.

Keywords

FAQs

Package last updated on 01 Feb 2018

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