Implementation of the queue data structure, using Typescript.
async function worker(amount: number, done: (result: number) => void) {
const result = await updateAmount(amount); // For exmaple API call
done(result);
}
const updateAmountQueued = Queue(worker);
updateAmountQueued(amount * multiplier, function callback(result) {
// Your result in result variable
});