Base ported to javascript