From 33c6f57150e4727e216796dc63e8dd5ceb587070 Mon Sep 17 00:00:00 2001 From: Erik Date: Sat, 20 Jun 2020 23:28:53 +0300 Subject: [PATCH] download as buffer --- util/Util.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/util/Util.js b/util/Util.js index 0b26f4e..8ce89ca 100644 --- a/util/Util.js +++ b/util/Util.js @@ -10,6 +10,15 @@ class Util { 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) { const result = [];