Skip to content

Commit 36f6c69

Browse files
author
AJ Keller
committed
FIX: remove support for node 5 and below
1 parent 5be1ccb commit 36f6c69

File tree

2 files changed

+9
-35
lines changed

2 files changed

+9
-35
lines changed

openBCIUtilities.js

Lines changed: 8 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,7 @@ let utilitiesModule = {
8585
// this.timeOfPacketArrival = this.time();
8686
// Grab the raw packet, make a copy of it.
8787
let rawPacket;
88-
if (k.getVersionNumber(process.version) >= 6) {
89-
// From introduced in node version 6.x.x
90-
rawPacket = Buffer.from(dataBuffer.slice(parsePosition, parsePosition + k.OBCIPacketSize));
91-
} else {
92-
rawPacket = new Buffer(dataBuffer.slice(parsePosition, parsePosition + k.OBCIPacketSize));
93-
}
88+
rawPacket = Buffer.from(dataBuffer.slice(parsePosition, parsePosition + k.OBCIPacketSize));
9489

9590
// Emit that buffer
9691
// this.emit('rawDataPacket', rawPacket);
@@ -107,11 +102,7 @@ let utilitiesModule = {
107102
if (tempBuf.length === 0) {
108103
dataBuffer = null;
109104
} else {
110-
if (k.getVersionNumber(process.version) >= 6) {
111-
dataBuffer = Buffer.from(tempBuf);
112-
} else {
113-
dataBuffer = new Buffer(tempBuf);
114-
}
105+
dataBuffer = Buffer.from(tempBuf);
115106
}
116107
// Move the parse position up one packet
117108
parsePosition = -1;
@@ -1121,12 +1112,8 @@ function parsePacketStandardAccel (o) {
11211112
if (o.scale) sampleObject.channelData = getChannelDataArray(o);
11221113
else sampleObject.channelDataCounts = getChannelDataArrayNoScale(o);
11231114

1124-
if (k.getVersionNumber(process.version) >= 6) {
1125-
// From introduced in node version 6.x.x
1126-
sampleObject.auxData = Buffer.from(o.rawDataPacket.slice(k.OBCIPacketPositionStartAux, k.OBCIPacketPositionStopAux + 1));
1127-
} else {
1128-
sampleObject.auxData = new Buffer(o.rawDataPacket.slice(k.OBCIPacketPositionStartAux, k.OBCIPacketPositionStopAux + 1));
1129-
}
1115+
sampleObject.auxData = Buffer.from(o.rawDataPacket.slice(k.OBCIPacketPositionStartAux, k.OBCIPacketPositionStopAux + 1));
1116+
11301117
// Get the sample number
11311118
sampleObject.sampleNumber = o.rawDataPacket[k.OBCIPacketPositionSampleNumber];
11321119
// Get the start byte
@@ -1169,12 +1156,8 @@ function parsePacketStandardRawAux (o) {
11691156
else sampleObject.channelDataCounts = getChannelDataArrayNoScale(o);
11701157

11711158
// Slice the buffer for the aux data
1172-
if (k.getVersionNumber(process.version) >= 6) {
1173-
// From introduced in node version 6.x.x
1174-
sampleObject.auxData = Buffer.from(o.rawDataPacket.slice(k.OBCIPacketPositionStartAux, k.OBCIPacketPositionStopAux + 1));
1175-
} else {
1176-
sampleObject.auxData = new Buffer(o.rawDataPacket.slice(k.OBCIPacketPositionStartAux, k.OBCIPacketPositionStopAux + 1));
1177-
}
1159+
sampleObject.auxData = Buffer.from(o.rawDataPacket.slice(k.OBCIPacketPositionStartAux, k.OBCIPacketPositionStopAux + 1));
1160+
11781161
// Get the sample number
11791162
sampleObject.sampleNumber = o.rawDataPacket[k.OBCIPacketPositionSampleNumber];
11801163
// Get the start byte
@@ -1528,11 +1511,7 @@ function getFromTimePacketRawAux (dataBuf) {
15281511
if (dataBuf.byteLength !== k.OBCIPacketSize) {
15291512
throw new Error(k.OBCIErrorInvalidByteLength);
15301513
}
1531-
if (k.getVersionNumber(process.version) >= 6) {
1532-
return Buffer.from(dataBuf.slice(k.OBCIPacketPositionTimeSyncAuxStart, k.OBCIPacketPositionTimeSyncAuxStop));
1533-
} else {
1534-
return new Buffer(dataBuf.slice(k.OBCIPacketPositionTimeSyncAuxStart, k.OBCIPacketPositionTimeSyncAuxStop));
1535-
}
1514+
return Buffer.from(dataBuf.slice(k.OBCIPacketPositionTimeSyncAuxStart, k.OBCIPacketPositionTimeSyncAuxStop));
15361515
}
15371516

15381517
/**
@@ -2024,12 +2003,7 @@ function stripToEOTBuffer (dataBuffer) {
20242003
}
20252004

20262005
if (indexOfEOT < dataBuffer.byteLength) {
2027-
if (k.getVersionNumber(process.version) >= 6) {
2028-
// From introduced in node version 6.x.x
2029-
return Buffer.from(dataBuffer.slice(indexOfEOT));
2030-
} else {
2031-
return new Buffer(dataBuffer.slice(indexOfEOT));
2032-
}
2006+
return Buffer.from(dataBuffer.slice(indexOfEOT));
20332007
} else {
20342008
return null;
20352009
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
},
5656
"homepage": "https://github.com/openbci/openbci_nodejs_utilities#readme",
5757
"engines": {
58-
"node": ">=4"
58+
"node": ">=6"
5959
},
6060
"semistandard": {
6161
"globals": [

0 commit comments

Comments
 (0)