feat(utils): Introduce promiseAll util (#5543)
This commit is contained in:
committed by
GitHub
parent
e4ce2f4e07
commit
f90ba02087
@@ -22,6 +22,7 @@ import {
|
||||
InjectEntityManager,
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { joinerConfig } from "../joiner-config"
|
||||
@@ -473,7 +474,7 @@ export default class InventoryService implements IInventoryService {
|
||||
return acc
|
||||
}, new Map())
|
||||
|
||||
return await Promise.all(
|
||||
return await promiseAll(
|
||||
updates.map(async (update) => {
|
||||
const levelId = levelMap
|
||||
.get(update.inventory_item_id)
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
isDefined,
|
||||
MedusaContext,
|
||||
MedusaError,
|
||||
promiseAll,
|
||||
} from "@medusajs/utils"
|
||||
import { EntityManager, FindManyOptions, In } from "typeorm"
|
||||
import { InventoryLevelService } from "."
|
||||
@@ -150,7 +151,7 @@ export default class ReservationItemService {
|
||||
}))
|
||||
)
|
||||
|
||||
const [newReservationItems] = await Promise.all([
|
||||
const [newReservationItems] = await promiseAll([
|
||||
reservationItemRepository.save(reservationItems),
|
||||
...data.map(
|
||||
async (data) =>
|
||||
@@ -228,7 +229,7 @@ export default class ReservationItemService {
|
||||
|
||||
ops.push(itemRepository.save(item))
|
||||
|
||||
await Promise.all(ops)
|
||||
await promiseAll(ops)
|
||||
|
||||
await this.eventBusService_?.emit?.(ReservationItemService.Events.UPDATED, {
|
||||
id: mergedItem.id,
|
||||
@@ -273,7 +274,7 @@ export default class ReservationItemService {
|
||||
)
|
||||
}
|
||||
|
||||
await Promise.all(ops)
|
||||
await promiseAll(ops)
|
||||
|
||||
await this.eventBusService_?.emit?.(ReservationItemService.Events.DELETED, {
|
||||
line_item_id: lineItemId,
|
||||
@@ -330,7 +331,7 @@ export default class ReservationItemService {
|
||||
|
||||
promises.push(itemRepository.softRemove(items))
|
||||
|
||||
await Promise.all(promises)
|
||||
await promiseAll(promises)
|
||||
|
||||
await this.eventBusService_?.emit?.(ReservationItemService.Events.DELETED, {
|
||||
ids: reservationItemId,
|
||||
|
||||
Reference in New Issue
Block a user