MCPcopy Index your code
hub / github.com/nodejs/node / test

Function test

test/sequential/test-buffer-creation-regression.js:6–16  ·  view source on GitHub ↗
(arrayBuffer, offset, length)

Source from the content-addressed store, hash-verified

4const assert = require('assert');
5
6function test(arrayBuffer, offset, length) {
7 const uint8Array = new Uint8Array(arrayBuffer, offset, length);
8 for (let i = 0; i < length; i += 1) {
9 uint8Array[i] = 1;
10 }
11
12 const buffer = Buffer.from(arrayBuffer, offset, length);
13 for (let i = 0; i < length; i += 1) {
14 assert.strictEqual(buffer[i], 1);
15 }
16}
17
18const acceptableOOMErrors = [
19 'Array buffer allocation failed',

Calls 1

fromMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…