import { EventType } from "../EventType.js";

/**
 *
 * @param {Entity[]} builders
 * @returns {Promise}
 */
export function whenAllEntitiesDestroyed(builders) {
    return Promise.all(builders.map(whenEntityDestroyed));
}

/**
 *
 * @param {Entity} builder
 * @returns {Promise}
 */
export function whenEntityDestroyed(builder) {
    return new Promise(function (resolve, reject) {
        builder.addEventListener(EventType.EntityRemoved, resolve);
    });
}
