UNPKG

@waku/rln

Version:

RLN (Rate Limiting Nullifier) implementation for Waku

21 lines (19 loc) 541 B
function coerce(o) { if (o instanceof Uint8Array && o.constructor.name === 'Uint8Array') { return o; } if (o instanceof ArrayBuffer) { return new Uint8Array(o); } if (ArrayBuffer.isView(o)) { return new Uint8Array(o.buffer, o.byteOffset, o.byteLength); } throw new Error('Unknown type, must be binary type'); } function fromString(str) { return new TextEncoder().encode(str); } function toString(b) { return new TextDecoder().decode(b); } export { coerce, fromString, toString };