npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cache-map

v1.1.0

Published

A TTL cache with an API compatible with an ES6 Map

Downloads

1,149

Readme

CacheMap

src/CacheMap.js:21-172

A TTL cache with an API compatible with an ES6 Map. Requires node 6+.

constructor

src/CacheMap.js:39-59

Parameters

  • ttl number The TTL for all entries added to this map
  • evictInterval number? How frequently to delete expired entries from the internal map
  • intialValues Iterable<[K, V]>? An iterable such as an array or another map containing the initial values to set in the map

Returns void

clear

src/CacheMap.js:64-66

Removes all key/value pairs from the Map object.

Returns void

delete

src/CacheMap.js:72-74

Removes any value associated with that key

Parameters

  • key K the key to delete

Returns boolean

entries

src/CacheMap.js:80-87

Returns Iterator<[K, V]> a new iterator object that contains an array of [key, value] for each element in the map that has not expired

forEach

src/CacheMap.js:94-98

Calls fn once for each non-expired key-value pair in the map object

Parameters

  • fn function (value: V, index: K, map: any): any the function to call
  • thisArg any the value of this when fn is called

Returns void

get

src/CacheMap.js:104-110

Parameters

  • key K

Returns V? the value associated with the key, or undefined if there is none or that entry has expired

has

src/CacheMap.js:115-120

Parameters

  • key K

Returns boolean indicates if the key has an associated value which hasn't expired

keys

src/CacheMap.js:125-129

Returns Iterator<K> a new iterator containing the keys of each non-expired entry in the map

set

src/CacheMap.js:135-138

Sets the value in the map, with a ttl of Date.now() + map.ttl

Parameters

  • key K
  • value V

Returns any the map

size

src/CacheMap.js:143-145

The number of non-expired key/value pairs in the map

Returns number

values

src/CacheMap.js:150-154

Returns Iterator<V> a new iterator containing the values of each non-expired entry in the map

deleteExpired

src/CacheMap.js:159-163

Removes every entry from the internal map that has already expired

Returns void