Socket
Socket
Sign inDemoInstall

cacheable-lookup

Package Overview
Dependencies
0
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.1.0 to 7.0.0

32

package.json
{
"name": "cacheable-lookup",
"version": "6.1.0",
"version": "7.0.0",
"description": "A cacheable dns.lookup(…) that respects TTL",
"engines": {
"node": ">=10.6.0"
"node": ">=14.16"
},

@@ -12,6 +12,10 @@ "files": [

],
"main": "source/index.js",
"types": "index.d.ts",
"type": "module",
"exports": {
"types": "./index.d.ts",
"default": "./source/index.js"
},
"scripts": {
"test": "xo && nyc --reporter=lcovonly --reporter=text ava && tsd"
"//test": "xo && nyc --reporter=lcovonly --reporter=text ava && tsd",
"test": "tsd"
},

@@ -36,3 +40,3 @@ "repository": {

"@types/keyv": "^3.1.1",
"ava": "^3.8.2",
"ava": "^4.3.3",
"benchmark": "^2.1.4",

@@ -42,7 +46,19 @@ "coveralls": "^3.0.9",

"nyc": "^15.0.0",
"proxyquire": "^2.1.3",
"quibble": "^0.6.14",
"quick-lru": "^5.1.0",
"tsd": "^0.11.0",
"quick-lru": "^5.1.0",
"xo": "^0.25.3"
},
"ava": {
"nodeArguments": [
"--loader=quibble"
]
},
"xo": {
"rules": {
"unicorn/import-index": "off",
"import/extensions": "off",
"import/no-useless-path-segments": "off"
}
}
}

@@ -17,4 +17,4 @@ # cacheable-lookup

```js
const http = require('http');
const CacheableLookup = require('cacheable-lookup');
import http from 'node:http';
import CacheableLookup from 'cacheable-lookup';

@@ -31,5 +31,5 @@ const cacheable = new CacheableLookup();

```js
const http = require('http');
const https = require('https');
const CacheableLookup = require('cacheable-lookup');
import http from 'node:http';
import https from 'node:https';
import CacheableLookup from 'cacheable-lookup';

@@ -54,3 +54,3 @@ const cacheable = new CacheableLookup();

Type: `object`<br>
Type: `object`\
Default: `{}`

@@ -62,3 +62,3 @@

Type: `Map` | [`Keyv`](https://github.com/lukechilds/keyv/)<br>
Type: `Map` | [`Keyv`](https://github.com/lukechilds/keyv/)\
Default: `new Map()`

@@ -73,5 +73,5 @@

```js
const http = require('http');
const CacheableLookup = require('cacheable-lookup');
const QuickLRU = require('quick-lru');
import http from 'node:http';
import CacheableLookup from 'cacheable-lookup';
import QuickLRU from 'quick-lru';

@@ -89,3 +89,3 @@ const cacheable = new CacheableLookup({

Type: `number`<br>
Type: `number`\
Default: `Infinity`

@@ -101,3 +101,3 @@

Type: `number`<br>
Type: `number`\
Default: `3600` (1 hour)

@@ -111,3 +111,3 @@

Type: `number`<br>
Type: `number`\
Default: `0.15`

@@ -123,3 +123,3 @@

Type: `dns.Resolver | dns.promises.Resolver`<br>
Type: `dns.Resolver | dns.promises.Resolver`\
Default: [`new dns.promises.Resolver()`](https://nodejs.org/api/dns.html#dns_class_dns_resolver)

@@ -131,3 +131,3 @@

Type: `Function`<br>
Type: `Function`\
Default: [`dns.lookup`](https://nodejs.org/api/dns.html#dns_dns_lookup_hostname_options_callback)

@@ -177,3 +177,3 @@

When `options.all` is `false`, then `callback(error, address, family, expires, ttl)` is called. <br>
When `options.all` is `false`, then `callback(error, address, family, expires, ttl)` is called.\
When `options.all` is `true`, then `callback(error, entries)` is called.

@@ -195,3 +195,3 @@

Returns an [entry object](#entry-object).<br>
Returns an [entry object](#entry-object).\
If `options.all` is true, returns an array of entry objects.

@@ -211,3 +211,3 @@

An asynchronous function which returns cached DNS lookup entries.<br>
An asynchronous function which returns cached DNS lookup entries.\
This is the base for `lookupAsync(hostname, options)` and `lookup(hostname, options, callback)`.

@@ -221,3 +221,3 @@

An asynchronous function which makes two DNS queries: A and AAAA. The result is cached.<br>
An asynchronous function which makes two DNS queries: A and AAAA. The result is cached.\
This is used by `query(hostname)` if no entry in the database is present.

@@ -259,6 +259,2 @@

- [cacheable-request](https://github.com/lukechilds/cacheable-request) - Wrap native HTTP requests with RFC compliant cache support
## License
MIT
- [cacheable-request](https://github.com/lukechilds/cacheable-request) - Wrap native HTTP requests with RFC compliant cache support

@@ -1,14 +0,13 @@

'use strict';
const {
import {
V4MAPPED,
ADDRCONFIG,
ALL,
promises: {
Resolver: AsyncResolver
},
lookup: dnsLookup
} = require('dns');
const {promisify} = require('util');
const os = require('os');
promises as dnsPromises,
lookup as dnsLookup
} from 'node:dns';
import {promisify} from 'node:util';
import os from 'node:os';
const {Resolver: AsyncResolver} = dnsPromises;
const kCacheableLookupCreateConnection = Symbol('cacheableLookupCreateConnection');

@@ -85,3 +84,3 @@ const kCacheableLookupInstance = Symbol('cacheableLookupInstance');

class CacheableLookup {
export default class CacheableLookup {
constructor({

@@ -101,2 +100,6 @@ cache = new Map(),

this._dnsLookup = lookup && promisify(lookup);
this.stats = {
cache: 0,
query: 0
};

@@ -219,6 +222,10 @@ if (this._resolver instanceof AsyncResolver) {

if (cached) {
this.stats.cache++;
}
if (!cached) {
const pending = this._pending[hostname];
if (pending) {
this.stats.cache++;
cached = await pending;

@@ -229,3 +236,3 @@ } else {

this._pending[hostname] = newPromise;
this.stats.query++;
try {

@@ -450,4 +457,1 @@ cached = await newPromise;

}
module.exports = CacheableLookup;
module.exports.default = CacheableLookup;
SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc