projeto-hit/backend/src/helpers/LoadBalanceWhatsSameQueue.ts

25 lines
590 B
TypeScript

const fsPromises = require("fs/promises");
const fs = require('fs')
import WhatsQueueIndex from "./WhatsQueueIndex";
// Delete a directory and its children
export const WhatsIndex = (whatsapps: Object[]) => {
let index: number = 0
if (WhatsQueueIndex.getIndex() >= whatsapps.length) {
WhatsQueueIndex.setIndex(0)
}
// console.log('WhatsQueueIndex.getIndex(): ', WhatsQueueIndex.getIndex())
index = +WhatsQueueIndex.getIndex()
WhatsQueueIndex.setIndex(+WhatsQueueIndex.getIndex() + 1)
console.log('WhatsQueue Index: ', index)
return index
}