TypeScript
Returning a value from a method

by Benny Neugebauer

private getSessionQueue(session_id: string): PriorityQueue {
  let queue = <PriorityQueue | undefined>this.queues.get(session_id);

  if (!queue) {
    queue = new PriorityQueue({maxRetries: 0});
    this.queues.set(session_id, queue);
  }

  return queue;
}

private getSessionQueue(session_id: string): PriorityQueue {
  let queue = <PriorityQueue | undefined>this.queues.get(session_id)

  if (queue) {
    return queue
  } else {
    queue = new PriorityQueue({maxRetries: 0})
    this.queues.set(session_id, queue)
    return queue
  }
}