UNPKG

base64-to-tensor

Version:

a pure js convert a base64 to a tensor object for node

21 lines 708 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toTypedArray = void 0; var trim_base64_1 = require("./trim-base64"); /** * Convert base64 to TypedArray. * * @param base64 a valid base64 encoded string. * @returns Uint8Array */ var toTypedArray = function (base64) { var bufferObject = Buffer.from((0, trim_base64_1.base64Replacer)(base64), "base64"); var arrayBuffer = new ArrayBuffer(bufferObject.length); var typedArray = new Uint8Array(arrayBuffer); for (var i = 0; i < bufferObject.length; ++i) { typedArray[i] = bufferObject[i]; } return typedArray; }; exports.toTypedArray = toTypedArray; //# sourceMappingURL=typed-array.js.map