这是一个32字节的缓冲区:
<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 02 9a>
删除所有前导零的最佳方法是什么?
预期输出为:
<Buffer 02 9a>
我目前的做法:
function removePaddingLeft(value) {
let pos
let i = 0
while (true) {
if (value[i] !== 0) break
pos = i++
}
return value.slice(pos + 1)
}