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

cacheable-lookup

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable-lookup - npm Package Compare versions

Comparing version 3.0.0 to 3.1.0

4

index.d.ts

@@ -94,2 +94,6 @@ import Keyv = require('keyv');

/**
* Removes outdated entries.
*/
tick(): void;
/**
* Attaches itself to an Agent instance.

@@ -96,0 +100,0 @@ */

@@ -8,3 +8,3 @@ 'use strict';

const kCacheableLookupData = Symbol('cacheableLookupData');
const kCacheableLookupCreateConnection = Symbol('cacheableLookupCreateConnection');
const kCacheableLookupInstance = Symbol('cacheableLookupInstance');

@@ -76,2 +76,7 @@

delete(key) {
this.values.delete(key);
this.expiries.delete(key);
}
clear() {

@@ -105,2 +110,3 @@ this.values.clear();

this._iface = getIfaceInfo();
this._tickLocked = false;

@@ -233,10 +239,30 @@ this.lookup = this.lookup.bind(this);

tick() {
if (this._tickLocked) {
return;
}
const now = Date.now();
for (const [hostname, expiry] of this._cache.expiries) {
if (now > expiry) {
this._cache.delete(hostname);
}
}
this._tickLocked = true;
setTimeout(() => {
this._tickLocked = false;
}, 1000).unref();
}
install(agent) {
verifyAgent(agent);
if (kCacheableLookupData in agent) {
if (kCacheableLookupCreateConnection in agent) {
throw new Error('CacheableLookup has been already installed');
}
agent[kCacheableLookupData] = agent.createConnection;
agent[kCacheableLookupCreateConnection] = agent.createConnection;
agent[kCacheableLookupInstance] = this;

@@ -247,5 +273,8 @@

options.lookup = this.lookup;
// Make sure the database is up to date
this.tick();
}
return agent[kCacheableLookupData](options, callback);
return agent[kCacheableLookupCreateConnection](options, callback);
};

@@ -257,3 +286,3 @@ }

if (agent[kCacheableLookupData]) {
if (agent[kCacheableLookupCreateConnection]) {
if (agent[kCacheableLookupInstance] !== this) {

@@ -263,5 +292,5 @@ throw new Error('The agent is not owned by this CacheableLookup instance');

agent.createConnection = agent[kCacheableLookupData];
agent.createConnection = agent[kCacheableLookupCreateConnection];
delete agent[kCacheableLookupData];
delete agent[kCacheableLookupCreateConnection];
delete agent[kCacheableLookupInstance];

@@ -268,0 +297,0 @@ }

2

package.json
{
"name": "cacheable-lookup",
"version": "3.0.0",
"version": "3.1.0",
"description": "A cacheable dns.lookup(…) that respects the TTL",

@@ -5,0 +5,0 @@ "engines": {

@@ -159,2 +159,6 @@ # cacheable-lookup

#### tick()
Removes outdated entries.
#### updateInterfaceInfo()

@@ -161,0 +165,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