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

consul

Package Overview
Dependencies
Maintainers
1
Versions
57
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

consul - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

22

lib/utils.js

@@ -151,2 +151,17 @@ "use strict";

/**
* Return BigInt or undefined if parse failed.
*/
function safeBigInt(value) {
if (value === undefined || value === null || value === "") {
return undefined;
}
try {
return BigInt(value);
} catch (err) {
return undefined;
}
}
/**
* Common options

@@ -560,5 +575,5 @@ */

function hasIndexChanged(index, prevIndex) {
if (typeof index !== "string" || !index) return false;
if (typeof prevIndex !== "string" || !prevIndex) return true;
return index !== prevIndex;
if (typeof index !== "bigint" || index <= 0) return false;
if (typeof prevIndex !== "bigint") return true;
return index > prevIndex;
}

@@ -604,2 +619,3 @@

exports.parseDuration = parseDuration;
exports.safeBigInt = safeBigInt;
exports.setTimeoutContext = setTimeoutContext;

@@ -606,0 +622,0 @@ exports.createServiceCheck = createServiceCheck;

18

lib/watch.js

@@ -21,3 +21,3 @@ const events = require("events");

options.wait = options.wait || "30s";
options.index = options.index || "0";
options.index = utils.safeBigInt(options.index || "0");

@@ -154,11 +154,19 @@ if (

const newIndex = res.headers["x-consul-index"];
const newIndex = utils.safeBigInt(res.headers["x-consul-index"]);
if (newIndex === undefined) {
return this._err(errors.Validation("Watch not supported"), res);
}
if (newIndex === 0n) {
return this._err(
errors.Consul("Consul returned zero index value"),
res
);
}
if (utils.hasIndexChanged(newIndex, this._options.index)) {
this._options.index = newIndex;
const prevIndex = this._options.index;
const reset = prevIndex !== undefined && newIndex < prevIndex;
if (reset || utils.hasIndexChanged(newIndex, prevIndex)) {
this._options.index = reset ? 0n : newIndex;
this.emit("change", data, res);

@@ -165,0 +173,0 @@ }

{
"name": "consul",
"version": "1.1.0",
"version": "1.2.0",
"description": "Consul client",

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

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