jean1880 / node-netconf Goto Github PK
View Code? Open in Web Editor NEWThis project forked from darylturner/node-netconf
Pure JavaScript NETCONF library for Node.js
License: ISC License
This project forked from darylturner/node-netconf
Pure JavaScript NETCONF library for Node.js
License: ISC License
Hi! ๐
Firstly, thanks for your work on this project! ๐
Today I used patch-package to patch [email protected]
for the project I'm working on.
The issue: the package changes hyphens to underscores in netconf reply, which is not really neccessary.
Here is the diff that solved my problem:
diff --git a/node_modules/node-netconf/lib/netconf.js b/node_modules/node-netconf/lib/netconf.js
index e5a015c..9a2fb84 100644
--- a/node_modules/node-netconf/lib/netconf.js
+++ b/node_modules/node-netconf/lib/netconf.js
@@ -25,7 +25,6 @@ class Client extends EventEmitter {
this._parse = this._parse.bind(this);
this._sendHello = this._sendHello.bind(this);
this._createError = this._createError.bind(this);
- this._objectHelper = this._objectHelper.bind(this);
this.open = this.open.bind(this);
this.close = this.close.bind(this);
@@ -49,10 +48,7 @@ class Client extends EventEmitter {
this.parseOpts = {
trim: true,
explicitArray: false,
emptyTag: true,
ignoreAttrs: false,
- tagNameProcessors: [this._objectHelper],
- attrNameProcessors: [this._objectHelper],
valueProcessors: [xml2js.processors.parseNumbers],
attrValueProcessors: [xml2js.processors.parseNumbers]
};
@@ -151,9 +147,9 @@ class Client extends EventEmitter {
if (err) {
return next(err);
}
- if (message.hello.session_id > 0) {
+ if (message.hello["session-id"] > 0) {
self.remoteCapabilities = message.hello.capabilities.capability;
- self.sessionID = message.hello.session_id;
+ self.sessionID = message.hello["session-id"];
self.connected = true;
next(null);
} else {
@@ -254,7 +250,7 @@ class Client extends EventEmitter {
if (self.raw) {
message.raw = xml;
}
- if (message.rpc_reply.hasOwnProperty('rpc_error')) {
+ if (message["rpc-reply"].hasOwnProperty('rpc-error')) {
return callback(self._createError(JSON.stringify(message), 'rpcError'), null);
}
return callback(null, message);
@@ -300,19 +296,6 @@ class Client extends EventEmitter {
Error.captureStackTrace(err, self._createError);
return err;
}
-
- /**
- * Replaces characters that prevent dot-style object navigation
- * @function _objectHelper
- * @private
- * @param {string} name String to transform
- * @return {string} Transformed string
- */
- _objectHelper(name) {
- // Replaces characters that prevent dot-style object navigation.
- return name.replace(/-|:/g, '_');
- }
-
}
module.exports.Client = Client;
This issue body was partially generated by patch-package.
When tags have prefixes like nc:rpc-reply, parsing fails.
Looks like there is no definition of close() function in the library.
I always get router.close() is not a function
Hi,
I notice there's only v1.1 in 'tag', could help publish v1.1.2, so that users can download the .zip or .tar.gz file and use it officially?
BR/Lei
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.