Reference implementation of burn in javascript.