Reimplement ReadItInFull in javascript