How to refer to `api.addPosterIcon` from inside of a function

The implementation of text/discourse-plugin snippets in themes is apparently as follows:

I’m not directly seeing any mention of a this instance here, which would imply it’s not related to JS’ implicit this, nor can it be api going out of scope, as the snippet is pasted in there.

Does this minimal example actually work, i.e. is it not an issue with the omitted code?

FWIW: the Discourse global and its currentUser field could be replaced with api.getCurrentUser() as well here: