a third approach to getting this working on nodejs

This approach replaces PRs #6 and #8 :smile: