Created JDownloaderClient.
This commit is contained in:
22
src/classes/utils/Utils.js
Normal file
22
src/classes/utils/Utils.js
Normal file
@@ -0,0 +1,22 @@
|
||||
class Utils {
|
||||
static async mapSeries(iterable, action) {
|
||||
for (const x of iterable) {
|
||||
await action(x);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
static wait(duration) {
|
||||
return new Promise((resolve) => {
|
||||
setTimeout(resolve, duration);
|
||||
});
|
||||
}
|
||||
|
||||
static parseTemplate(template, data) {
|
||||
return Object.keys(data).reduce((str, key) => {
|
||||
return str.replace(new RegExp(`{${key}}`, 'gi'), data[key]);
|
||||
}, template);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Utils;
|
Reference in New Issue
Block a user