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

Function zeroPad

js/src/static_dependencies/ethers/utils/data.js:127–143  ·  view source on GitHub ↗
(data, length, left)

Source from the content-addressed store, hash-verified

125 return "0x" + bytes;
126}
127function zeroPad(data, length, left) {
128 const bytes = getBytes(data);
129 assert(length >= bytes.length, "padding exceeds data length", "BUFFER_OVERRUN", {
130 buffer: new Uint8Array(bytes),
131 length: length,
132 offset: length + 1
133 });
134 const result = new Uint8Array(length);
135 result.fill(0);
136 if (left) {
137 result.set(bytes, length - bytes.length);
138 }
139 else {
140 result.set(bytes, 0);
141 }
142 return hexlify(result);
143}
144/**
145 * Return the [[DataHexString]] of %%data%% padded on the **left**
146 * to %%length%% bytes.

Callers 2

zeroPadValueFunction · 0.70
zeroPadBytesFunction · 0.70

Calls 4

assertFunction · 0.90
setMethod · 0.80
getBytesFunction · 0.70
hexlifyFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…