Buffer
Buffer.subarray()
Creates a shared view of the selected bytes, with an exclusive end index. Negative indices count from the end. Use Buffer.from(view) when an independent copy is required.
Formal Syntax & Structure
nodejs syntaxnodejs
buf.subarray([start[, end]])Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| start | integer | Start index, default 0. |
| end | integer | Exclusive end, default buffer length. |
Return Value
Buffer
View sharing the source storage.
Working Example
Example Snippetnodejs
import { Buffer } from "node:buffer";const bytes = Buffer.from([1, 2, 3]);console.log([...bytes.subarray(1)]);