Re-writes of ruby functions in JavaScript