Comparing version 1.0.1 to 1.0.2
@@ -6,5 +6,3 @@ const EventEmitter = require('node:events') | ||
const sjson = require('secure-json-parse') | ||
const Debug = require('debug') | ||
const debug = Debug('pg-notify') | ||
const sleep = util.promisify(setTimeout) | ||
@@ -31,2 +29,4 @@ | ||
this.channels = {} | ||
/* c8 ignore next */ | ||
this.debug = process.env.DEBUG && process.env.DEBUG.includes('pg-notify') | ||
} | ||
@@ -49,5 +49,5 @@ | ||
debug('[emit] channel: ', channel) | ||
debug('[emit] payload: ', payload) | ||
debug('[emit] state: ', this.state) | ||
this._debug('[emit] channel: ', channel) | ||
this._debug('[emit] payload: ', payload) | ||
this._debug('[emit] state: ', this.state) | ||
@@ -58,3 +58,3 @@ return this.client.query(`NOTIFY ${format.ident(channel)}, ${parsedPayload}`) | ||
async on (channel, listener) { | ||
debug('[subscribe]', channel) | ||
this._debug('[subscribe]', channel) | ||
if (this.state !== states.connected) { | ||
@@ -114,3 +114,3 @@ throw new Error('[PGPubSub]: not connected') | ||
async _reconnect (force) { | ||
debug('[_reconnect] state: ', this.state) | ||
this._debug('[_reconnect] state: ', this.state) | ||
@@ -149,3 +149,3 @@ if (!this.reconnectMaxRetries) { | ||
this.client.on('notification', (message) => { | ||
debug('[_setupClient] notification', message) | ||
this._debug('[_setupClient] notification', message) | ||
@@ -160,3 +160,3 @@ try { | ||
this.client.on('error', err => { | ||
debug('[_setupClient] error') | ||
this._debug('[_setupClient] error') | ||
@@ -171,3 +171,3 @@ if (this.reconnectRetries > this.reconnectMaxRetries) { | ||
debug('[_setupClient] init listeners') | ||
this._debug('[_setupClient] init listeners') | ||
if (Object.keys(this.channels).length) { | ||
@@ -181,6 +181,13 @@ for (const channel in this.channels) { | ||
this.reconnectRetries = 0 | ||
debug('[_setupClient] init listeners done') | ||
this._debug('[_setupClient] init listeners done') | ||
} | ||
_debug (...args) { | ||
/* c8 ignore next 3 */ | ||
if (this.debug) { | ||
console.log(...args) | ||
} | ||
} | ||
} | ||
module.exports = PGPubSub |
{ | ||
"name": "pg-notify", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Postgres pubsub client", | ||
@@ -44,3 +44,2 @@ "type": "module", | ||
"dependencies": { | ||
"debug": "^4.3.4", | ||
"pg": "^8.11.3", | ||
@@ -52,3 +51,3 @@ "pg-format": "^1.0.4", | ||
"@types/pg": "^8.10.9", | ||
"ava": "^5.3.1", | ||
"ava": "^6.0.1", | ||
"benchmark": "^2.1.4", | ||
@@ -59,3 +58,3 @@ "c8": "8.0.1", | ||
"standard": "^17.1.0", | ||
"tsd": "^0.29.0" | ||
"tsd": "^0.30.1" | ||
}, | ||
@@ -62,0 +61,0 @@ "tsd": { |
@@ -6,5 +6,3 @@ import EventEmitter from 'node:events' | ||
import sjson from 'secure-json-parse' | ||
import Debug from 'debug' | ||
const debug = Debug('pg-notify') | ||
const sleep = util.promisify(setTimeout) | ||
@@ -31,2 +29,4 @@ | ||
this.channels = {} | ||
/* c8 ignore next */ | ||
this.debug = process.env.DEBUG && process.env.DEBUG.includes('pg-notify') | ||
} | ||
@@ -49,5 +49,5 @@ | ||
debug('[emit] channel: ', channel) | ||
debug('[emit] payload: ', payload) | ||
debug('[emit] state: ', this.state) | ||
this._debug('[emit] channel: ', channel) | ||
this._debug('[emit] payload: ', payload) | ||
this._debug('[emit] state: ', this.state) | ||
@@ -58,3 +58,3 @@ return this.client.query(`NOTIFY ${format.ident(channel)}, ${parsedPayload}`) | ||
async on (channel, listener) { | ||
debug('[subscribe]', channel) | ||
this._debug('[subscribe]', channel) | ||
if (this.state !== states.connected) { | ||
@@ -114,3 +114,3 @@ throw new Error('[PGPubSub]: not connected') | ||
async _reconnect (force) { | ||
debug('[_reconnect] state: ', this.state) | ||
this._debug('[_reconnect] state: ', this.state) | ||
@@ -149,3 +149,3 @@ if (!this.reconnectMaxRetries) { | ||
this.client.on('notification', (message) => { | ||
debug('[_setupClient] notification', message) | ||
this._debug('[_setupClient] notification', message) | ||
@@ -160,3 +160,3 @@ try { | ||
this.client.on('error', err => { | ||
debug('[_setupClient] error') | ||
this._debug('[_setupClient] error') | ||
@@ -171,3 +171,3 @@ if (this.reconnectRetries > this.reconnectMaxRetries) { | ||
debug('[_setupClient] init listeners') | ||
this._debug('[_setupClient] init listeners') | ||
if (Object.keys(this.channels).length) { | ||
@@ -181,6 +181,13 @@ for (const channel in this.channels) { | ||
this.reconnectRetries = 0 | ||
debug('[_setupClient] init listeners done') | ||
this._debug('[_setupClient] init listeners done') | ||
} | ||
_debug (...args) { | ||
/* c8 ignore next 3 */ | ||
if (this.debug) { | ||
console.log(...args) | ||
} | ||
} | ||
} | ||
export default PGPubSub |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15476
3
312
4
- Removeddebug@^4.3.4
- Removeddebug@4.4.0(transitive)
- Removedms@2.1.3(transitive)