<commit_before>**A simple LRU cache supporting O(1) set, get and eviction of old keys**

## Installation

```bash
$ npm install lru
```

### Example

```javascript
var LRU = require('lru').LRU;

var cache = new LRU(2),
    evicted

cache.on('evict',function(data) { evicted = data });

cache.set('foo', 'bar');
cache.get('foo'); //=> bar

cache.set('foo2', 'bar2');
cache.get('foo2'); //=> bar2

cache.set('foo3', 'bar3');
cache.get('foo3'); //=> bar3,  evicted = { key: 'foo', value: 'bar' }
```

### API

#### `LRU( length )`
Create a new LRU cache that stores `length` elements before evicted the least recently used.

**Returns**: the newly created LRU cache


#### `.set( key, value )`
Set the value of the key and mark the key as most recently used.

**Returns**: `value`

#### `.on( event, callback )`
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}`.


### Credits

A big thanks to [Dusty Leary](https://github.com/dustyleary) who
finished the library.

### License

MIT<commit_msg>Typo fix #7<commit_after>**A simple LRU cache supporting O(1) set, get and eviction of old keys**

## Installation

```bash
$ npm install lru
```

### Example

```javascript
var LRU = require('lru').LRU;

var cache = new LRU(2),
    evicted

cache.on('evict',function(data) { evicted = data });

cache.set('foo', 'bar');
cache.get('foo'); //=> bar

cache.set('foo2', 'bar2');
cache.get('foo2'); //=> bar2

cache.set('foo3', 'bar3');
cache.get('foo3'); //=> bar3,  evicted = { key: 'foo', value: 'bar' }
```

### API

#### `require('lru').LRU( length )`
Create a new LRU cache that stores `length` elements before evicting the least recently used.

**Returns**: the newly created LRU cache


#### `.set( key, value )`
Set the value of the key and mark the key as most recently used.

**Returns**: `value`

#### `.on( event, callback )`
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}`.


### Credits

A big thanks to [<NAME>](https://github.com/dustyleary) who
finished the library.

### License

MIT
{'fraction_non_alphanumeric': 0.175054704595186, 'fraction_numerical': 0.009190371991247264, 'mean_word_length': 4.303944315545244, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 10, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7670033', 'n_tokens_mistral': 795, 'n_tokens_neox': 755, 'n_words': 276}