@runejs/common
Version:
Common logging, networking, compression, and other miscellaneous functionality for RuneJS.
25 lines • 965 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
Array.prototype.forEachAsync = function (callback) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
if (this === undefined || this === null || !Array.isArray(this) || this.length < 1) {
return;
}
return yield Promise.all(this.map(callback));
});
};
Map.prototype.forEachAsync = function (callback) {
return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () {
if (this === undefined || this === null || !(this instanceof Map) || this.size < 1) {
return;
}
const promises = new Array(this.size);
let i = 0;
for (const [key, value] of this) {
promises[i++] = callback(value, key, this);
}
return yield Promise.all(promises);
});
};
//# sourceMappingURL=foreach-async.js.map