libp2p-middleware-evm
Version:
EVM middleware for libp2p
24 lines • 679 B
JavaScript
// Helper to use instead of .at() which isn't available on Uint8ArrayList
export function getByteAt(array, index) {
if (typeof array.at === 'function') {
return array.at(index) ?? 0;
}
if (typeof array.get === 'function') {
return array.get(index) ?? 0;
}
return 0;
}
// Helper to ensure we have a Uint8Array
export function ensureUint8Array(data) {
if (data instanceof Uint8Array) {
return data;
}
if (typeof data.subarray === 'function') {
return data.subarray();
}
if (Array.isArray(data)) {
return new Uint8Array(data);
}
return new Uint8Array();
}
//# sourceMappingURL=mock-types.js.map