Expose services as a consumable external module

you have this logic above in getTokenPosOfNode.  Just use that helper here.