@waku/rln
Version:
RLN (Rate Limiting Nullifier) implementation for Waku
20 lines (17 loc) • 512 B
JavaScript
import BASES from './util/bases.js';
/**
* Turns a `Uint8Array` into a string.
*
* Supports `utf8`, `utf-8` and any encoding supported by the multibase module.
*
* Also `ascii` which is similar to node's 'binary' encoding.
*/
function toString(array, encoding = 'utf8') {
const base = BASES[encoding];
if (base == null) {
throw new Error(`Unsupported encoding "${encoding}"`);
}
// strip multibase prefix
return base.encoder.encode(array).substring(1);
}
export { toString };