Skip to content

ArrayBuffer.isView() and buffer.buffer property #4420

@dy

Description

@dy

Hello!
ArrayBuffer.isView thinks of node buffers as views to ArrayBuffers. Is this correct behaviour?

var buffer = Buffer(0);
ArrayBuffer.isView(buffer); //true

Because this is a bit non-intuitive, as ArrayBuffer.isView() is expected to detect TypedArrays, DataViews and stuff with ArrayBuffer as a .buffer parameter (according to MDN). Indeed, buffer.buffer instanceof ArrayBuffer — that is awesome (finding that out while writing this), but at least that needs to be covered by docs (?).
Also buffer.buffer, which is ArrayBuffer, has byteLength very different from the Buffer.length. That is because of shared memory for Buffers, etc, but makes that inner ArrayBuffer useless, unfortunately.

.isView in spec.

Thank you for reading, just close if the issue is insubstantial IYO :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bufferIssues and PRs related to the buffer subsystem.questionIssues that look for answers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions