nodejs能进行位运算吗?文档中没有
buffer只是针对字节的
3 回复
能的
crc32中的简单例子
function crcTable(arr, append) {
var crc, i, l;
// if we're in append mode, don't reset crc
// if arr is null or undefined, reset table and return
if (typeof crcTable.crc === 'undefined' || !append || !arr) {
crcTable.crc = 0 ^ -1;
if (!arr) {
return;
}
}
// store in temp variable for minor speed gain
crc = crcTable.crc;
for (i = 0, l = arr.length; i < l; i += 1) {
crc = (crc >>> 8) ^ table[(crc ^ arr[i]) & 0xff];
}
crcTable.crc = crc;
return crc ^ -1;
}