JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2421
  • Score
    100M100P100Q115319F
  • License Unlicense

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

Package Exports

  • map-lru

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (map-lru) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

MapLRU

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

NPM version Build 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'
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