Comparing version 3.1.1 to 3.2.0
@@ -1,3 +0,1 @@ | ||
'use strict'; | ||
const net = require('net'); | ||
@@ -176,2 +174,3 @@ const is = require('is-type-of'); | ||
* - {Number} id - packet id | ||
* - {String} [tips] - packet tips, show tips on error | ||
* - {Buffer} data - binary data | ||
@@ -187,2 +186,3 @@ * - {Boolean} [oneway] - oneway or not | ||
err.id = packet.id; | ||
err.tips = packet.tips; | ||
err.data = packet.data.toString('base64'); | ||
@@ -209,2 +209,3 @@ if (packet.oneway) { | ||
id: packet.id, | ||
tips: packet.tips, | ||
dataLength: packet.data.length, | ||
@@ -255,2 +256,11 @@ bufferSize1: this._socket.bufferSize, | ||
sendPromise(packet) { | ||
return new Promise((resolve, reject) => { | ||
this.send(packet, (err, data) => { | ||
if (err) return reject(err); | ||
resolve(data); | ||
}); | ||
}); | ||
} | ||
_finishInvoke(id) { | ||
@@ -257,0 +267,0 @@ this._invokes.delete(id); |
{ | ||
"name": "tcp-base", | ||
"version": "3.1.1", | ||
"version": "3.2.0", | ||
"description": "A base class for tcp client with basic functions", | ||
@@ -14,4 +14,3 @@ "main": "lib/base.js", | ||
"cov": "egg-bin cov", | ||
"ci": "npm run lint && npm run cov", | ||
"contributors": "contributors" | ||
"ci": "npm run lint && npm run cov" | ||
}, | ||
@@ -34,10 +33,4 @@ "repository": { | ||
}, | ||
"ci": { | ||
"version": "14, 16, 18", | ||
"os": "linux" | ||
}, | ||
"devDependencies": { | ||
"contributors": "^0.5.1", | ||
"egg-bin": "^5.2.0", | ||
"egg-ci": "^2.1.0", | ||
"eslint": "^8.23.0", | ||
@@ -44,0 +37,0 @@ "eslint-config-egg": "^12.0.0", |
@@ -32,4 +32,2 @@ # tcp-base | ||
```js | ||
'use strict'; | ||
const TCPBase = require('tcp-base'); | ||
@@ -62,3 +60,3 @@ | ||
get heartBeatPacket() { | ||
return new Buffer([ 255, 255, 255, 255, 0, 0, 0, 0 ]); | ||
return Buffer.from([ 255, 255, 255, 255, 0, 0, 0, 0 ]); | ||
} | ||
@@ -72,4 +70,4 @@ } | ||
const body = new Buffer('hello'); | ||
const data = new Buffer(8 + body.length); | ||
const body = Buffer.from('hello'); | ||
const data = Buffer.alloc(8 + body.length); | ||
data.writeInt32BE(1, 0); | ||
@@ -76,0 +74,0 @@ data.writeInt32BE(body.length, 4); |
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
6
417
16437
4
135