{ "name": "lru-queue", "version": "0.1.0", "description": "LRU Queue", "author": { "name": "Mariusz Nowak", "email": "medyk@medikoo.com", "url": "http://www.medikoo.com/" }, "repository": { "type": "git", "url": "git://github.com/medikoo/lru-queue.git" }, "keywords": [ "lru", "cache", "queue" ], "dependencies": { "es5-ext": "~0.10.2" }, "devDependencies": { "tad": "~0.1.21" }, "scripts": { "test": "node node_modules/tad/bin/tad" }, "license": "MIT", "readme": "# lru-queue\n## Size limited queue based on [LRU](http://en.wikipedia.org/wiki/Least_Recently_Used#LRU) algorithm\n\n_Originally derived from [memoizee](https://github.com/medikoo/memoize) package._\n\nIt's low-level utility meant to be used internally within cache algorithms. It backs up [`max`](https://github.com/medikoo/memoize#limiting-cache-size) functionality in [memoizee](https://github.com/medikoo/memoize) project.\n\n### Installation\n\n\t$ npm install lru-queue\n\nTo port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)\n\n### Usage\n\nCreate queue, and provide a limit\n\n```javascript\nvar lruQueue = require('lru-queue');\nvar queue = lruQueue(3); // limit size to 3\n```\n\nEach queue exposes three methods:\n\n#### queue.hit(id)\n\nRegisters hit for given _id_ (must be plain string).\n\n```javascript\nqueue.hit('raz'); // size: 1\n```\n\nIf hit doesn't remove any old item from list it returns `undefined`, otherwise it returns removed _id_.\n\n\n```javascript\nqueue.hit('dwa'); // undefined, size: 2\nqueue.hit('trzy'); // undefined, size: 3 (at max)\nqueue.hit('raz'); // undefined, size: 3 (at max)\nqueue.hit('dwa'); // undefined, size: 3 (at max)\nqueue.hit('cztery'); // 'trzy', size: 3 (at max)\n\n```\n\n#### queue.delete(id);\n\n_id's_ can be cleared from queue externally\n\n```javascript\nqueue.delete('raz'); // size: 2\nqueue.delete('cztery'); // size: 1\n```\n\n#### queue.clear();\n\nResets queue\n\n```javascript\nqueue.clear(); // size: 0\n```\n\n### Tests [![Build Status](https://travis-ci.org/medikoo/lru-queue.png)](https://travis-ci.org/medikoo/lru-queue)\n\n\t$ npm test\n\n", "readmeFilename": "README.md", "bugs": { "url": "https://github.com/medikoo/lru-queue/issues" }, "homepage": "https://github.com/medikoo/lru-queue", "_id": "lru-queue@0.1.0", "_shasum": "2738bd9f0d3cf4f84490c5736c48699ac632cda3", "_from": "lru-queue@0.1", "_resolved": "https://registry.npmjs.org/lru-queue/-/lru-queue-0.1.0.tgz" }