parser for the sam format in javascript