UNPKG

@blockcerts/hashlink-verifier

Version:
11 lines (10 loc) 314 B
export function stringToUint8Array (data: string | Uint8Array): Uint8Array { if (typeof data === 'string') { // convert data to Uint8Array return new TextEncoder().encode(data); } if (!(data instanceof Uint8Array)) { throw new TypeError('"data" be a string or Uint8Array.'); } return data; }