23 lines
478 B
JavaScript
Raw Normal View History

2021-06-12 00:19:25 -05:00
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;