I have a class that executes CRUD operations in my NodeJS app. It is designed to queue operations and execute them sequentially. As of now, I am using this class in multiple other files, and as a result, there are multiple instances of it, each with their own separate queue.
My goal is to be able to share the same queue across all other modules without having multiple instances, so that all of the CRUD operations are sequentially executed in the order they are called.
//SomeFile.js
var data = new CRUDQueue();
data.addRecord(someRecord); //Pushes an add operation to the internal queue
//SomeOtherFile.js
var data = new CRUDQueue();
data.deleteRecord(someRecord); //Pushes a delete operation to the internal queue
Is there a way I can share the same CRUDQueue object across both of these files? Preferably without using global or passing it to the constructor?