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

Function testFastSwap16

test/parallel/test-buffer-swap-fast.js:7–14  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5const assert = require('assert');
6
7function testFastSwap16() {
8 const buf = Buffer.from([0x01, 0x02, 0x03, 0x04]);
9 const expected = Buffer.from([0x02, 0x01, 0x04, 0x03]);
10 const padded = Buffer.alloc(256);
11 buf.copy(padded);
12 padded.swap16();
13 assert.deepStrictEqual(padded.subarray(0, 4), expected);
14}
15
16function testFastSwap32() {
17 const buf = Buffer.from([0x01, 0x02, 0x03, 0x04]);

Callers 1

Calls 4

allocMethod · 0.80
swap16Method · 0.80
copyMethod · 0.65
fromMethod · 0.45

Tested by

no test coverage detected