download as buffer

This commit is contained in:
Erik 2020-06-20 23:28:53 +03:00
parent d9aa6bb0e9
commit 33c6f57150

View File

@ -10,6 +10,15 @@ class Util {
throw new Error("Class may not be instantiated."); throw new Error("Class may not be instantiated.");
} }
static downloadAsBuffer(source) {
return new Promise((resolve, reject) => {
fetch(source).then(res => {
if(res.ok) resolve(res.buffer());
else reject(res.statusText);
});
});
}
static readdirRecursive(directory) { static readdirRecursive(directory) {
const result = []; const result = [];