Comparing version 0.2.2 to 1.0.0
@@ -1,2 +0,2 @@ | ||
var LRU = require('../').LRU | ||
var LRU = require('../') | ||
@@ -9,11 +9,14 @@ var cache = new LRU(2); | ||
cache.set('foo', 'bar'); | ||
cache.get('foo'); //=> bar | ||
cache.set('foo', 'bar'); // => 'bar' | ||
cache.get('foo'); // => 'bar' | ||
cache.set('foo2', 'bar2'); | ||
cache.get('foo2'); //=> bar2 | ||
cache.set('foo2', 'bar2'); // => 'bar2' | ||
cache.get('foo2'); // => 'bar2' | ||
cache.set('foo3', 'bar3'); | ||
cache.get('foo3'); //=> bar3, evicted = { key: 'foo', value: 'bar' } | ||
cache.set('foo3', 'bar3'); // => 'bar3' | ||
cache.get('foo3'); // => 'bar3' | ||
console.log(evicted) | ||
console.log(cache.remove('foo2')) // => { key: 'foo2', value: 'bar2' } | ||
console.log(cache.remove('foo4')) // => undefined | ||
console.log(cache.length) // => 1 | ||
console.log(evicted) // => evicted = { key: 'foo', value: 'bar' } |
var events = require('events'); | ||
var util = require('util'); | ||
var LRU = exports.LRU = function (max) { | ||
var LRU = module.exports = function (max) { | ||
events.EventEmitter.call(this); | ||
@@ -6,0 +6,0 @@ this.cache = {} |
{ | ||
"name": "lru", | ||
"description": "A simple O(1) LRU cache", | ||
"version": "0.2.2", | ||
"version": "1.0.0", | ||
"author": "Chris O'Hara <cohara87@gmail.com>", | ||
"main": "index", | ||
"bugs": { | ||
"mail": "cohara87@gmail.com" | ||
}, | ||
"homepage": { | ||
"url": "http://github.com/chriso/lru" | ||
}, | ||
"homepage": "http://github.com/chriso/lru", | ||
"repository": { | ||
@@ -17,10 +12,9 @@ "type": "git", | ||
}, | ||
"bugs": { | ||
"url": "http://github.com/chriso/lru/issues" | ||
}, | ||
"engines": { | ||
"node": ">= 0.4.0" | ||
}, | ||
"licenses": [ | ||
{ | ||
"type": "MIT" | ||
} | ||
], | ||
"license": "MIT", | ||
"devDependencies": { | ||
@@ -27,0 +21,0 @@ "vows": "^0.8.1" |
@@ -14,3 +14,3 @@ # lru | ||
```javascript | ||
var LRU = require('lru').LRU; | ||
var LRU = require('lru'); | ||
@@ -28,4 +28,7 @@ var cache = new LRU(2), | ||
cache.set('foo3', 'bar3'); | ||
cache.get('foo3'); //=> bar3, evicted = { key: 'foo', value: 'bar' } | ||
cache.set('foo3', 'bar3'); // => evicted = { key: 'foo', value: 'bar' } | ||
cache.get('foo3'); // => 'bar3' | ||
cache.remove('foo2') // => {key: 'foo2', value: 'bar2'} | ||
cache.remove('foo4') // => undefined | ||
cache.length // => 1 | ||
``` | ||
@@ -35,3 +38,3 @@ | ||
#### `require('lru').LRU( length )` | ||
#### `LRU( length )` | ||
Create a new LRU cache that stores `length` elements before evicting the least recently used. | ||
@@ -42,2 +45,6 @@ | ||
#### Properties | ||
##### `.length` | ||
The number of keys currently in the cache. | ||
#### Methods | ||
@@ -58,2 +65,7 @@ | ||
##### `.remove( key )` | ||
Remove the key/value pair from the cache. | ||
**Returns**: an associative array containing `{key: <key>, value: <value>}` | ||
##### `.on( event, callback )` | ||
@@ -60,0 +72,0 @@ Respond to events. Currently only the `evict` event is implemented. When a key is evicted, the callback is executed with an associative array containing the evicted key: `{key: key, value: value}`. |
var assert = require('assert'); | ||
var vows = require('vows'); | ||
var LRU = require('../').LRU; | ||
var LRU = require('../'); | ||
@@ -5,0 +5,0 @@ function keys(obj) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11172
248
1
0
78