fixes #1150 buffer slice issue in JS