Day two

The fluorescent lights hum loudly within the quaint office given to you by your captors. It wouldn't have surprised you if it had been windowless but instead it has a grand view overlooking a busy street intersection. Just beyond that intersection there's a park and a lake, and people playing in the sun. Is having this view somehow worse, you ponder while prying the window slightly ajar to let some summer breeze inside.

After yesterday's shock you went home to re-read the contract. This then led you through the usual phases of shock, grief and anger. Finally, you arrived at a station called: malicious complicance.

"I will do exactly as specified in the contract. If it's comments they want, it's comments they'll get. However, there might just be more than a little poetry interleaved within the code. They won't find out in time either since they just ordered me to hand in my laptop with the completed work when I'm done."

From your rucksack you pull out your armaments, one roleplaying cheat sheet named "Chance", and another poetry cheat sheet named "Utils".

You lean back in the creaky office chair and do a preparatory twirl, before leaning forward over the work laptop and start perusing the code to comment.


These source files are found in the enterprise/ directory located at the root of this project.

call-center.mjs

export class CallCenter {
queue = []

receptionists = []

callerCalling(caller) {
this.queue.push(caller)
}

receptionistSigningIn(receptionist) {
this.receptionists.push(receptionist)
}

receptionistSigningOff(receptionist) {
this.receptionists = this.receptionists.filter(
(item) => item !== receptionist
)
}

isQueued(caller) {
return !!this.queue.find((item) => item === caller)
}

handleCaller() {
const receptionist = this.receptionists.find((r) => r.talkingTo === null)
if (!receptionist) {
return false
}
const caller = this.queue.shift()
receptionist.talkTo(caller)
return true
}

lunchbreak() {
this.receptionists.forEach((r) => {
if (r.talkingTo === null) {
return
}
this.queue.push(r.talkingTo)
r.hangup()
})
}
}

caller.mjs

export class Caller {
#srcNumber = null

constructor(srcNumber) {
this.#srcNumber = srcNumber
}
}

index.mjs

export * from './caller.mjs'
export * from './call-center.mjs'
export * from './receptionist.mjs'

receptionist.mjs

import { randomUUID } from 'node:crypto'

export class Receptionist {
talkingTo = null

constructor(callSign = randomUUID()) {
this.callSign = callSign
}

talkTo(caller) {
this.talkingTo = caller
}

hangup() {
this.talkingTo = null
}
}