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

Function bytes

test/fixtures/wpt/wasm/jsapi/wasm-module-builder.js:15–33  ·  view source on GitHub ↗
(...input)

Source from the content-addressed store, hash-verified

13// - a single string; the returned buffer will contain the char codes of all
14// contained characters.
15function bytes(...input) {
16 if (input.length == 1 && typeof input[0] == 'array') input = input[0];
17 if (input.length == 1 && typeof input[0] == 'string') {
18 let len = input[0].length;
19 let view = new Uint8Array(len);
20 for (let i = 0; i < len; i++) view[i] = input[0].charCodeAt(i);
21 return view.buffer;
22 }
23 let view = new Uint8Array(input.length);
24 for (let i = 0; i < input.length; i++) {
25 let val = input[i];
26 if (typeof val == 'string') {
27 assertEquals(1, val.length, 'string inputs must have length 1');
28 val = val.charCodeAt(0);
29 }
30 view[i] = val | 0;
31 }
32 return view.buffer;
33}
34
35// Header declaration constants
36var kWasmH0 = 0;

Callers 15

pipeFunction · 0.50
__init__Method · 0.50
testBytesAsyncFunction · 0.50
testBytesAsyncLimitFunction · 0.50
testBytesAsyncAbortFunction · 0.50
testBytesEmptyFunction · 0.50
testBytesStringSourceFunction · 0.50

Calls 1

assertEqualsFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…