Skip to content

Commit

Permalink
[major] Drop support for Node.js < 10
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Jul 14, 2021
1 parent e814110 commit 552b506
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 23 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ jobs:
strategy:
matrix:
node:
- 8
- 10
- 12
- 14
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ environment:
- nodejs_version: '14'
- nodejs_version: '12'
- nodejs_version: '10'
- nodejs_version: '8'
platform:
- x86
matrix:
Expand Down
9 changes: 3 additions & 6 deletions lib/buffer-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ function _mask(source, mask, output, offset, length) {
* @public
*/
function _unmask(buffer, mask) {
// Required until https://github.com/nodejs/node/issues/9006 is resolved.
const length = buffer.length;
for (let i = 0; i < length; i++) {
for (let i = 0; i < buffer.length; i++) {
buffer[i] ^= mask[i & 3];
}
}
Expand Down Expand Up @@ -103,19 +101,18 @@ function toBuffer(data) {

try {
const bufferUtil = require('bufferutil');
const bu = bufferUtil.BufferUtil || bufferUtil;

module.exports = {
concat,
mask(source, mask, output, offset, length) {
if (length < 48) _mask(source, mask, output, offset, length);
else bu.mask(source, mask, output, offset, length);
else bufferUtil.mask(source, mask, output, offset, length);
},
toArrayBuffer,
toBuffer,
unmask(buffer, mask) {
if (buffer.length < 32) _unmask(buffer, mask);
else bu.unmask(buffer, mask);
else bufferUtil.unmask(buffer, mask);
}
};
} catch (e) /* istanbul ignore next */ {
Expand Down
9 changes: 1 addition & 8 deletions lib/permessage-deflate.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const zlib = require('zlib');

const bufferUtil = require('./buffer-util');
const Limiter = require('./limiter');
const { kStatusCode, NOOP } = require('./constants');
const { kStatusCode } = require('./constants');

const TRAILER = Buffer.from([0x00, 0x00, 0xff, 0xff]);
const kPerMessageDeflate = Symbol('permessage-deflate');
Expand Down Expand Up @@ -418,13 +418,6 @@ class PerMessageDeflate {
this._deflate[kTotalLength] = 0;
this._deflate[kBuffers] = [];

//
// An `'error'` event is emitted, only on Node.js < 10.0.0, if the
// `zlib.DeflateRaw` instance is closed while data is being processed.
// This can happen if `PerMessageDeflate#cleanup()` is called at the wrong
// time due to an abnormal WebSocket closure.
//
this._deflate.on('error', NOOP);
this._deflate.on('data', deflateOnData);
}

Expand Down
7 changes: 1 addition & 6 deletions lib/validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,7 @@ function _isValidUTF8(buf) {
}

try {
let isValidUTF8 = require('utf-8-validate');

/* istanbul ignore if */
if (typeof isValidUTF8 === 'object') {
isValidUTF8 = isValidUTF8.Validation.isValidUTF8; // utf-8-validate@<3.0.0
}
const isValidUTF8 = require('utf-8-validate');

module.exports = {
isValidStatusCode,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"main": "index.js",
"browser": "browser.js",
"engines": {
"node": ">=8.3.0"
"node": ">=10.0.0"
},
"files": [
"browser.js",
Expand Down

0 comments on commit 552b506

Please sign in to comment.