Skip to content
Permalink
Browse files

stream: simplify uint8ArrayToBuffer helper

The fallback code is no longer used when exporting to readable-stream.

Refs: #29514

PR-URL: #30041
Fixes: #30040
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information
lpinca authored and targos committed Oct 20, 2019
1 parent ae39039 commit 21a43bd2fda1b74162ab6644f637f7c7b1af9d8c
Showing with 6 additions and 17 deletions.
  1. +6 −17 lib/stream.js
@@ -21,9 +21,9 @@

'use strict';

const { Buffer } = require('buffer');
const pipeline = require('internal/streams/pipeline');
const eos = require('internal/streams/end-of-stream');
const internalBuffer = require('internal/buffer');

// Note: export Stream before Readable/Writable/Duplex/...
// to avoid a cross-reference(require) issues
@@ -42,19 +42,8 @@ Stream.finished = eos;
Stream.Stream = Stream;

Stream._isUint8Array = require('internal/util/types').isUint8Array;

try {
const internalBuffer = require('internal/buffer');
Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) {
return new internalBuffer.FastBuffer(chunk.buffer,
chunk.byteOffset,
chunk.byteLength);
};
} catch (e) { // eslint-disable-line no-unused-vars
}

if (!Stream._uint8ArrayToBuffer) {
Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) {
return Buffer.prototype.slice.call(chunk);
};
}
Stream._uint8ArrayToBuffer = function _uint8ArrayToBuffer(chunk) {
return new internalBuffer.FastBuffer(chunk.buffer,
chunk.byteOffset,
chunk.byteLength);
};

0 comments on commit 21a43bd

Please sign in to comment.
You can’t perform that action at this time.