本文整理匯總了TypeScript中@ephox/sand.Uint8Array函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript Uint8Array函數的具體用法?TypeScript Uint8Array怎麽用?TypeScript Uint8Array使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Uint8Array函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
const uriToBlob = function (base64, type) {
let i;
const str = Window.atob(base64);
const arr = Uint8Array(str.length);
for (i = 0; i < arr.length; i++) {
arr[i] = str.charCodeAt(i);
}
return Blob([arr], { type });
};
示例2: function
const base64ToBlob = function (base64, type) {
const buff = Window.atob(base64);
const bytes = Uint8Array(buff.length);
for (let i = 0; i < bytes.length; i++) {
bytes[i] = buff.charCodeAt(i);
}
return new Blob([bytes], { type });
};
示例3: Promise
return new Promise(function (resolve) {
let str, arr, i;
const uriParts = parseDataUri(uri);
// Might throw error if data isn't proper base64
try {
str = Window.atob(uriParts.data);
} catch (e) {
resolve(new Blob([]));
return;
}
arr = Uint8Array(str.length);
for (i = 0; i < arr.length; i++) {
arr[i] = str.charCodeAt(i);
}
resolve(new Blob([arr], { type: uriParts.type }));
});