Skip to content

Commit 57c58fc

Browse files
author
AJ Keller
committed
FIX: Buffer problems
1 parent 091d840 commit 57c58fc

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v0.3.4
2+
3+
### Bug Fixes
4+
5+
* Protect and ensure buffer returned for raw data packets
6+
17
# v0.3.3
28

39
### Enhancements

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "openbci-utilities",
3-
"version": "0.3.3",
3+
"version": "0.3.4",
44
"description": "The official utility package of Node.js SDK for the OpenBCI Biosensor Boards.",
55
"main": "dist/openbci-utilities.js",
66
"module": "src/index.js",

src/utilities.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,12 @@ let utilitiesModule = {
9898
// Overwrite the dataBuffer with a new buffer
9999
let tempBuf;
100100
if (parsePosition > 0) {
101-
tempBuf = Buffer.concat([dataBuffer.slice(0, parsePosition), dataBuffer.slice(parsePosition + k.OBCIPacketSize)], dataBuffer.byteLength - k.OBCIPacketSize);
101+
tempBuf = Buffer.concat([
102+
Buffer.from(dataBuffer.slice(0, parsePosition)),
103+
Buffer.from(dataBuffer.slice(parsePosition + k.OBCIPacketSize))
104+
]);
102105
} else {
103-
tempBuf = dataBuffer.slice(k.OBCIPacketSize);
106+
tempBuf = Buffer.from(dataBuffer.slice(k.OBCIPacketSize));
104107
}
105108
if (tempBuf.length === 0) {
106109
dataBuffer = null;

0 commit comments

Comments
 (0)