Port utils to JavaScript