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

ttl-mem-cache

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ttl-mem-cache - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

5

lib/cache.js

@@ -66,4 +66,7 @@ 'use strict';

del(key) {
const item = this.store.get(key);
const success = this.store.delete(key);
this.emit('dispose', key);
if (item) {
this.emit('dispose', key, item.value);
}
return success;

@@ -70,0 +73,0 @@ }

2

package.json
{
"name": "ttl-mem-cache",
"version": "2.0.0",
"version": "2.1.0",
"description": "A in memory time to live cache with streaming support.",

@@ -5,0 +5,0 @@ "main": "lib/cache.js",

@@ -236,8 +236,8 @@ # ttl-mem-cache

When an item is disposed (deleted) from the cache. Emits the `key` of the item.
When an item is disposed (deleted) from the cache. Emits the `key` of the item and the item itself.
```js
const cache = new Cache();
cache.on('dispose', (key) => {
console.log(key); // outputs: 'a'
cache.on('dispose', (key, item) => {
console.log(key, item); // outputs: "a, {foo: 'bar'}"
});

@@ -244,0 +244,0 @@ cache.set('a', {foo: 'bar'});

@@ -277,6 +277,21 @@ 'use strict';

tap.test('cache.del() - remove set value - should return true', (t) => {
const cache = new Cache();
cache.set('foo', 'bar');
t.equal(cache.del('foo'), true);
t.end();
});
tap.test('cache.del() - remove unset value - should return false', (t) => {
const cache = new Cache();
cache.set('foo', 'bar');
t.equal(cache.del('bar'), false);
t.end();
});
tap.test('cache.del() - remove set value - should emit dispose event on removal', (t) => {
const cache = new Cache();
cache.on('dispose', (key) => {
cache.on('dispose', (key, item) => {
t.equal(key, 'foo');
t.equal(item, 'bar');
t.end();

@@ -283,0 +298,0 @@ });

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