@blockcerts/hashlink-verifier
Version:
Handling hashlinks in Blockcerts
21 lines (20 loc) • 679 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextEncoder = exports.TextDecoder = void 0;
exports.stringToUint8Array = stringToUint8Array;
// browser TextDecoder/TextEncoder
/* eslint-env browser */
const TextDecoder = self.TextDecoder;
exports.TextDecoder = TextDecoder;
const TextEncoder = self.TextEncoder;
exports.TextEncoder = TextEncoder;
function stringToUint8Array(data) {
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;
}