Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ylru

Package Overview
Dependencies
Maintainers
3
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ylru - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

5

History.md
1.2.0 / 2017-07-18
==================
* feat: support lru.keys (#2)
1.1.0 / 2017-07-04

@@ -3,0 +8,0 @@ ==================

@@ -67,2 +67,25 @@ 'use strict';

keys() {
const cacheKeys = new Set();
const now = Date.now();
for (const entry of this.cache.entries()) {
checkEntry(entry);
}
for (const entry of this._cache.entries()) {
checkEntry(entry);
}
function checkEntry(entry) {
const key = entry[0];
const item = entry[1];
if (entry[1].value && (!entry[1].expired) || item.expired >= now) {
cacheKeys.add(key);
}
}
return Array.from(cacheKeys.keys());
}
_update(key, item) {

@@ -69,0 +92,0 @@ this.cache.set(key, item);

2

package.json
{
"name": "ylru",
"description": "Extends LRU base on hashlru",
"version": "1.1.0",
"version": "1.2.0",
"homepage": "https://github.com/node-modules/ylru",

@@ -6,0 +6,0 @@ "repository": {

@@ -67,4 +67,26 @@ # ylru

### lru.keys()
Get all unexpired cache keys from lru, due to the strategy of ylru, the `keys`' length may greater than `max`.
```js
const lru = new LRU(3);
lru.set('key 1', 'value 1');
lru.set('key 2', 'value 2');
lru.set('key 3', 'value 3');
lru.set('key 4', 'value 4');
lru.keys(); // [ 'key 4', 'key 1', 'key 2', 'key 3']
// cache: {
// 'key 4': 'value 4',
// }
// _cache: {
// 'key 1': 'value 1',
// 'key 2': 'value 2',
// 'key 3': 'value 3',
// }
```
## License
[MIT](LICENSE)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc