2024-05-08 19:55:36 +03:00
|
|
|
export const ZERO_ELEMENT = 0
|
2024-05-08 23:13:37 +03:00
|
|
|
|
2024-05-08 19:55:36 +03:00
|
|
|
export function getBatches(array, batchSize) {
|
2024-05-08 23:13:37 +03:00
|
|
|
const batches = []
|
|
|
|
while (array.length) {
|
|
|
|
batches.push(array.splice(ZERO_ELEMENT, batchSize))
|
|
|
|
}
|
|
|
|
return batches
|
|
|
|
}
|
|
|
|
|
2024-05-08 19:55:36 +03:00
|
|
|
export async function sleep(ms) {
|
2024-05-08 23:13:37 +03:00
|
|
|
return await new Promise((resolve) => setTimeout(resolve, ms))
|
|
|
|
}
|