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

Function arrayBufferToUnsignedBigInt

lib/internal/crypto/random.js:560–572  ·  view source on GitHub ↗

* @param {ArrayBuffer} buf An ArrayBuffer. * @returns {bigint}

(buf)

Source from the content-addressed store, hash-verified

558 * @returns {bigint}
559 */
560function arrayBufferToUnsignedBigInt(buf) {
561 const length = ArrayBufferPrototypeGetByteLength(buf);
562 const chars = Array(length * 2);
563 const view = new DataView(buf);
564
565 for (let i = 0; i < length; i++) {
566 const val = DataViewPrototypeGetUint8(view, i);
567 chars[2 * i] = numberToHexCharCode(val >> 4);
568 chars[2 * i + 1] = numberToHexCharCode(val & 0xf);
569 }
570
571 return BigInt(`0x${StringFromCharCodeApply(chars)}`);
572}
573
574function unsignedBigIntToBuffer(bigint, name) {
575 if (bigint < 0) {

Callers

nothing calls this directly

Calls 2

ArrayFunction · 0.85
numberToHexCharCodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…