added javascript version of the stuff. works reasonably bag.