本文整理匯總了TypeScript中@ephox/sand.Window類的典型用法代碼示例。如果您正苦於以下問題:TypeScript Window類的具體用法?TypeScript Window怎麽用?TypeScript Window使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Window類的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;
uri = parseDataUri(uri);
// Might throw error if data isn't proper base64
try {
str = Window.atob(uri.data);
} catch (e) {
resolve(new Blob([]));
return;
}
arr = new Uint8Array(str.length);
for (i = 0; i < arr.length; i++) {
arr[i] = str.charCodeAt(i);
}
resolve(new Blob([arr], { type: uri.type }));
});