MCPcopy Create free account
hub / github.com/ccxt/ccxt / toBeArray

Function toBeArray

js/src/static_dependencies/ethers/utils/maths.js:182–197  ·  view source on GitHub ↗
(_value)

Source from the content-addressed store, hash-verified

180 * Converts %%value%% to a Big Endian Uint8Array.
181 */
182export function toBeArray(_value) {
183 const value = getUint(_value, "value");
184 if (value === BN_0) {
185 return new Uint8Array([]);
186 }
187 let hex = value.toString(16);
188 if (hex.length % 2) {
189 hex = "0" + hex;
190 }
191 const result = new Uint8Array(hex.length / 2);
192 for (let i = 0; i < result.length; i++) {
193 const offset = i * 2;
194 result[i] = parseInt(hex.substring(offset, offset + 2), 16);
195 }
196 return result;
197}
198/**
199 * Returns a [[HexString]] for %%value%% safe to use as a //Quantity//.
200 *

Callers 5

getValueFunction · 0.90
_packFunction · 0.90
getValueFunction · 0.90
_packFunction · 0.90
toQuantityFunction · 0.70

Calls 3

parseIntFunction · 0.85
getUintFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…