The above idiom feels hard to read, and there likely to be hard to maintain.  What about something like?

'''
if (port)
  port.postEvent('talkilla.worker-ready');
else
  this.ports.broadcastEvent('talkilla.worker-ready');
'''

And then something similar below?

The simplicity of regular if statements and method invocations feels like it adds to maintainability more than the slight code duplication detracts.