Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

map-lru

Package Overview
Dependencies
Maintainers
0
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

map-lru

"Least Recently Used" (LRU) cache compatible to ES6 Map

  • 2.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
2.7K
decreased by-32.44%
Maintainers
0
Weekly downloads
 
Created
Source

MapLRU

"Least Recently Used" (LRU) cache compatible to ES6 Map

NPM version Build Status Coverage Status

Useful for caching with limited memory usage. API compatible with built-in Map object.

Install

$ npm install map-lru

Usage

import MapLRU from 'map-lru' // ES5
// const MapLRU = require('map-lru') // commonJs
const cache = new MapLRU(10)

cache.set('♥', '♥♥♥')

cache.has('♥');
//=> true
cache.get('♥');
//=> '♥♥♥'
cache.last
//=> '♥'
cache.size
//=> 1

API

new MapLRU(maxSize)

Creates a new instance

Parameters

  • maxSize Number max. size of the LRU cache.

Additional methods

  • last

    Returns the last accessed key.

    Returns Any

  • peek(key)

    Get an item without marking it as recently used.

    Parameters

    • key Any
  • keysAccessed()

    keys in order of access - last one is most recently used one.

    Returns Iterator Iterator object


Default Map methods

License

Unlicense

Keywords

FAQs

Package last updated on 14 Aug 2024

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