How do you create a function which can be awaited, in which case it has one set of behaviour, or called directly, in which case it has another?
I asked this very question on Stack Overflow and got a great answer. This is the answer.
The first commit is the answer posted. The second commit is the answer in the comments.