//bitmap 判断是否存在 Buffer.prototype.hasBit=function(num){ const n=num>>3; const k=num%8; return (this[n]&1<<k)!==0 } Buffer.prototype.setBit=function(num){ const n=num>>3; const k=num%8; this[n]=this[n]|(1<<k); } Buffer.prototype.delBit=function(num){ const n=num>>3; const k=num%8; this[n]=this[n]&~(1<<k); } const buf=require('fs').readFileSync('a.bit'); console.log(buf.setBit(2)) console.log(buf.hasBit(1)) console.log(buf.hasBit(2)) console.log(buf.hasBit(92)) console.log(buf.hasBit(99))