sloki-node-client
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -51,4 +51,2 @@ const implementedTransports = ['tcp','tls']; | ||
} | ||
console.log(MyClient); | ||
} | ||
@@ -55,0 +53,0 @@ } |
{ | ||
"name": "sloki-node-client", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "NodeJS Client for Sloki", | ||
@@ -11,3 +11,3 @@ "main": "index.js", | ||
"type": "git", | ||
"url": "git+https://github.com/franck34/sloki-node-client.git" | ||
"url": "git+https://github.com/sloki-project/sloki-node-client.git" | ||
}, | ||
@@ -21,5 +21,5 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/franck34/sloki-node-client/issues" | ||
"url": "https://github.com/sloki-project/sloki-node-client/issues" | ||
}, | ||
"homepage": "https://github.com/franck34/sloki-node-client#readme", | ||
"homepage": "https://github.com/sloki-project/sloki-node-client#readme", | ||
"dependencies": { | ||
@@ -26,0 +26,0 @@ "JSONStream": "^1.3.5", |
# Sloki-node-client | ||
A NodeJS Client for [Sloki](https://github.com/franck34/sloki) | ||
A NodeJS Client for [Sloki](https://github.com/sloki-project/sloki) | ||
@@ -7,3 +7,3 @@ [![Join the chat at https://gitter.im/sloki-server/community](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/sloki-server/community) | ||
[![alt packagequality](http://npm.packagequality.com/shield/sloki-node-client.svg)](http://packagequality.com/#?package=sloki-node-client) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/franck34/sloki-node-client/badge.svg?targetFile=package.json)](https://snyk.io/test/github/franck34/sloki-node-client?targetFile=package.json) | ||
[![Known Vulnerabilities](https://snyk.io/test/github/sloki-project/sloki-node-client/badge.svg?targetFile=package.json)](https://snyk.io/test/github/sloki-project/sloki-node-client?targetFile=package.json) | ||
@@ -10,0 +10,0 @@ ----- |
@@ -27,3 +27,3 @@ const net = require('net'); | ||
getCommands(reject, resolve) { | ||
this._request('commands', null, (err, commands) => { | ||
this._request(['commands', (err, commands) => { | ||
@@ -36,23 +36,5 @@ if (err) { | ||
for (let command in commands) { | ||
this[command] = (param, option, cb) => { | ||
let params = []; | ||
if (typeof param === "function") { | ||
cb = param; | ||
params = undefined; | ||
} else if (typeof option === "function") { | ||
cb = option; | ||
option = undefined; | ||
params.push(param); | ||
} else { | ||
params.push(param); | ||
if (option) params.push(option); | ||
} | ||
if (params && params.length === 0) { | ||
params = undefined; | ||
} | ||
this._request(command, params, cb); | ||
this[command] = (...args) => { | ||
args.unshift(command); | ||
this._request(args); | ||
return this; | ||
@@ -62,3 +44,3 @@ } | ||
return resolve(); | ||
}); | ||
}]); | ||
} | ||
@@ -169,2 +151,4 @@ | ||
//console.log(req); | ||
//@TODO: take a look at fastify to speed up stringify() | ||
@@ -195,12 +179,16 @@ this.conn.write(JSON.stringify(req)); | ||
_request(method, params, callback) { | ||
if (typeof params === "function") { | ||
callback = params; | ||
params = null; | ||
} | ||
if (callback) { | ||
this._requestWithCallback(uuid(), method, params, callback); | ||
_request(args) { | ||
let method = args.shift(); | ||
let callback = null; | ||
if (typeof args[args.length-1] === "function") { | ||
callback = args.pop(); | ||
if (!args.length) { | ||
args = undefined; | ||
} | ||
this._requestWithCallback(uuid(), method, args, callback); | ||
} else { | ||
return this._requestWithPromise(uuid(), method, params); | ||
if (!args.length) { | ||
args = undefined; | ||
} | ||
return this._requestWithPromise(uuid(), method, args); | ||
} | ||
@@ -207,0 +195,0 @@ } |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9
1
13150
202