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

zookeeper

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zookeeper - npm Package Compare versions

Comparing version 5.2.0 to 5.2.1

3

CHANGELOG.md

@@ -0,1 +1,4 @@

#### v 5.2.1 (2022-01-05)
* fix: explicitly handle async JavaScript failures. Pull request [293](https://github.com/yfinkelstein/node-zookeeper/pull/293) by @davidvujic
#### v 5.2.0 (2022-01-05)

@@ -2,0 +5,0 @@ * feat: add a boolean "path exists" function, wrapping the "exists" function. Pull request [291](https://github.com/yfinkelstein/node-zookeeper/pull/291) by @davidvujic

2

examples/addtask.js

@@ -7,3 +7,3 @@ const { constants } = require('./wrapper');

// eslint-disable-next-line no-bitwise
const message = await createNode(client, '/tasks/task-', constants.ZOO_PERSISTENT | constants.ZOO_PERSISTENT_SEQUENTIAL, data);
const message = await createNode(client, '/tasks/task-', constants.ZOO_PERSISTENT | constants.ZOO_PERSISTENT_SEQUENTIAL, undefined, data);
notifier.emit('addTask', message);

@@ -10,0 +10,0 @@ }

@@ -6,2 +6,17 @@ const { constants } = require('./wrapper');

async function verifyResultCodeCheckInAsyncCall(client) {
const tempNode = '/my-temporary-node-to-verify-async-call';
const data = 'HELLOWORLD';
const version = 0;
createNodes(client, [tempNode], constants.ZOO_EPHEMERAL);
const res = await client.set(tempNode, data, version);
logger.log(`The client.set result: ${JSON.stringify(res)}`);
client.set('this-node-does-not-exist', data, version)
.then(() => logger.error('THIS WILL NOT HAPPEN.'))
.catch((error) => logger.log(`The error is: ${error}`));
}
async function verifyNonExisting(client) {

@@ -26,2 +41,3 @@ const tempNode = '/my-temporary-node';

await verifyNonExisting(client);
await verifyResultCodeCheckInAsyncCall(client);
}

@@ -28,0 +44,0 @@

@@ -5,4 +5,17 @@ const deprecationLog = (className, methodName) => {

function findZkConstantByCode(code, constants) {
const fallback = ['unknown', code];
try {
const res = Object.entries(constants).find(([, v]) => v === code);
return res || fallback;
} catch (e) {
return fallback;
}
}
exports = module.exports = {
deprecationLog,
findZkConstantByCode,
};

@@ -6,2 +6,3 @@ // needed to not break the interface

const zkConstants = require('./constants');
const { findZkConstantByCode } = require('./helper');

@@ -254,3 +255,10 @@ function isTruthy(data) {

};
fn.bind(this)(...args, callback);
const res = fn.bind(this)(...args, callback);
if (res < 0) {
const [key, value] = findZkConstantByCode(res, zkConstants);
reject(new Error(`fn: "${fn.name}" args: "${args}" result: "${key} ${value}"`));
}
});

@@ -257,0 +265,0 @@ }

{
"name": "zookeeper",
"description": "apache zookeeper client (zookeeper async API v3.4.x - v3.7.x)",
"version": "5.2.0",
"version": "5.2.1",
"author": "Yuri Finkelstein <yurif2003@yahoo.com>",

@@ -6,0 +6,0 @@ "license": "MIT",

@@ -99,2 +99,4 @@ # node-zookeeper

:green_circle: New since 5.2.1: :red_circle: the async functions will reject, when the underlying client returns an error code. This is a bug fix. Before this, errors were failing silently.
* `init(options)`

@@ -101,0 +103,0 @@ * `connect(options, connect_cb)`

const sinon = require('sinon');
const test = require('ava');
const { deprecationLog } = require('../../../lib/helper');
const zkConstants = require('../../../lib/constants');
const { deprecationLog, findZkConstantByCode } = require('../../../lib/helper');

@@ -33,1 +34,21 @@ class Test {

});
test('finds the BAD ARGUMENTS constant', (t) => {
t.plan(2);
const expected = -8;
const res = findZkConstantByCode(expected, zkConstants);
t.is(res[0], 'ZBADARGUMENTS');
t.is(res[1], expected);
});
test('finds constants with fallback', (t) => {
t.plan(2);
const expected = 4711;
const res = findZkConstantByCode(expected, zkConstants);
t.is(res[0], 'unknown');
t.is(res[1], expected);
});
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