Some explanation of code
Following code in JavaScript equals number > 0 ? Math.floor(number) : Math.ceil(number)
number |= 0
~~number
But according to my test, ~~x is much faster than Math.floor(x) for random positive double value. So you can use bit operation instead of Math.floor(x) and parseInt(x)
if (block != null) blocks.set(blockPos, block); can be simplified to if (block) blocks.set(blockPos, block); or just block && blocks.set(blockPos, block);
Because null in JavaScript is considered as false value, and && operator will not do things after it if things before it is a false value.