Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buffer: make FastBuffer safe to construct #36587

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion lib/internal/buffer.js
Expand Up @@ -949,7 +949,14 @@ function writeFloatBackwards(val, offset = 0) {
return offset;
}

class FastBuffer extends Uint8Array {}
class FastBuffer extends Uint8Array {
// Using an explicit constructor here is necessary to avoid relying on
// `Array.prototype[Symbol.iterator]`, which can be mutated by users.
// eslint-disable-next-line no-useless-constructor
aduh95 marked this conversation as resolved.
Show resolved Hide resolved
constructor(bufferOrLength, byteOffset, length) {
super(bufferOrLength, byteOffset, length);
}
}

function addBufferPrototypeMethods(proto) {
proto.readBigUInt64LE = readBigUInt64LE;
Expand Down