Skip to content
/ mru Public

Most recently used fixed size overflowing array.

License

Notifications You must be signed in to change notification settings

dsandor/mru

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status dependencies Status npm version Known Vulnerabilities

mru

Most recently used fixed size overflowing array. The last n elements pushed to array last, old ones drop out of the array.

install

npm i mru --save

usage

const MruArray = require('mru');

// Create a default MruArray with a limit of 10 elements.
let mruArrayLimitedToTen = new MruArray();

// Create an MruArray with a limit of 5 elements.
let mruArrayLimitedToFive = new MruArray(5);

// Add 20 items to a 10 limited MruArray, 0 - 19.

let mruArray = new MruArray();
for(let i = 0; i < 20; i++) {
  mruArray.push(i);
}

// mruArray[0] will equal 10
// mruArray[9] will equal 19