Skip to content

Commit 88e1ec4

Browse files
Fix PR comments
1 parent 9a9c464 commit 88e1ec4

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

ios-device-lib-stdio-handler.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const HeaderSize = 4;
1313
class IOSDeviceLibStdioHandler extends EventEmitter {
1414
constructor() {
1515
super();
16-
this._unfinishedMessage = new Buffer(0);
16+
this._unfinishedMessage = Buffer.alloc(0);
1717
}
1818

1919
startReadingData() {
@@ -57,12 +57,13 @@ class IOSDeviceLibStdioHandler extends EventEmitter {
5757
// Get the message length header.
5858
const messageSizeBuffer = data.slice(0, HeaderSize);
5959
const messageLength = bufferpack.unpack(">i", messageSizeBuffer)[0];
60+
const dataLengthWithoutHeader = data.length - HeaderSize;
6061

61-
if (messageLength > data.length - HeaderSize) {
62+
if (messageLength > dataLengthWithoutHeader) {
6263
// Less than one message in the buffer.
6364
// Store the unfinished message untill the next call of the function.
6465
this._unfinishedMessage = data;
65-
} else if (data.length - 4 > messageLength) {
66+
} else if (dataLengthWithoutHeader > messageLength) {
6667
// More than one message in the buffer.
6768
const messageBuffer = this._getMessageFromBuffer(data, messageLength);
6869

@@ -82,7 +83,7 @@ class IOSDeviceLibStdioHandler extends EventEmitter {
8283
const concatenatedMessage = Buffer.concat([this._unfinishedMessage, data]);
8384

8485
// Clear the unfinished message buffer.
85-
this._unfinishedMessage = new Buffer(0);
86+
this._unfinishedMessage = Buffer.alloc(0);
8687
this._unpackMessages(concatenatedMessage);
8788
} else {
8889
// While debugging the data here contains one character - \0, null or 0.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ios-device-lib",
3-
"version": "0.1.1",
3+
"version": "0.2.0",
44
"description": "",
55
"types": "./typings/ios-device-lib.d.ts",
66
"main": "index.js",

0 commit comments

Comments
 (0)