set-lru

0.1.0 • Public • Published

set-lru Travis-CI.org Build Status Coveralls.io Coverage Rating

Unordered set adapter for LRU.

Usage

Usage is pretty self-explanatory; a lot of the semantics are identical to LRU.

For example, the constructor forwards all arguments to LRU's constructor.

This module exports the following methods:

  • add(obj) - adds an object to the set
  • remove(obj) - removes an object from the set
  • contains(obj) - tests if the set contains an object
  • clear() - clears the entire set
  • .contents (property) - an array containing all of the set's elements
  • .length (property) - the number of elements in the set
  • on(name, fn) (from EventEmitter) - adds event handlers (currently only responds to 'evict')
  • hash(obj) - can be overridden to change how objects are translated to unique keys (usually not called directly)

The evict event in this case simply hands you the object that was evicted, as the LRU key is an implementation detail.

License

Licensed under the MIT License.

You can find a copy of it in LICENSE.

Package Sidebar

Install

npm i set-lru

Weekly Downloads

1

Version

0.1.0

License

MIT

Last publish

Collaborators

  • qix