As @stocky-spoon-28903 noted, you should be able to do this by putting the function in a variable, or perhaps even in a separate module which can be loaded by a test harness as well.
A simple sketch: https://gist.github.com/lukehoban/a6a6ebd96678598a1a745eb3570d55eb