Port helper methods to JavaScript