Port utils to JavaScript

Progress towards #143.

Signed-off-by: Don Naegely <naegelyd@gmail.com>