basant307/AI_Governance_Project
045
1function isBuffer(value) {2 return Buffer.isBuffer(value) || value instanceof Uint8Array3}4 5function isEncoding(encoding) {6 return Buffer.isEncoding(encoding)7}8 9function alloc(size, fill, encoding) {10 return Buffer.alloc(size, fill, encoding)11}12 13function allocUnsafe(size) {14 return Buffer.allocUnsafe(size)15}16 17function allocUnsafeSlow(size) {18 return Buffer.allocUnsafeSlow(size)19}20 21function byteLength(string, encoding) {22 return Buffer.byteLength(string, encoding)23}24 25function compare(a, b) {26 return Buffer.compare(a, b)27}28 29function concat(buffers, totalLength) {30 return Buffer.concat(buffers, totalLength)31}32 33function copy(source, target, targetStart, start, end) {34 return toBuffer(source).copy(target, targetStart, start, end)35}36 37function equals(a, b) {38 return toBuffer(a).equals(b)39}40 41function fill(buffer, value, offset, end, encoding) {42 return toBuffer(buffer).fill(value, offset, end, encoding)43}44 45function from(value, encodingOrOffset, length) {46 return Buffer.from(value, encodingOrOffset, length)47}48 49function includes(buffer, value, byteOffset, encoding) {50 return toBuffer(buffer).includes(value, byteOffset, encoding)51}52 53function indexOf(buffer, value, byfeOffset, encoding) {54 return toBuffer(buffer).indexOf(value, byfeOffset, encoding)55}56 57function lastIndexOf(buffer, value, byteOffset, encoding) {58 return toBuffer(buffer).lastIndexOf(value, byteOffset, encoding)59}60 61function swap16(buffer) {62 return toBuffer(buffer).swap16()63}64 65function swap32(buffer) {66 return toBuffer(buffer).swap32()67}68 69function swap64(buffer) {70 return toBuffer(buffer).swap64()71}72 73function toBuffer(buffer) {74 if (Buffer.isBuffer(buffer)) return buffer75 return Buffer.from(buffer.buffer, buffer.byteOffset, buffer.byteLength)76}77 78function toString(buffer, encoding, start, end) {79 return toBuffer(buffer).toString(encoding, start, end)80}81 82function write(buffer, string, offset, length, encoding) {83 return toBuffer(buffer).write(string, offset, length, encoding)84}85 86function readDoubleBE(buffer, offset) {87 return toBuffer(buffer).readDoubleBE(offset)88}89 90function readDoubleLE(buffer, offset) {91 return toBuffer(buffer).readDoubleLE(offset)92}93 94function readFloatBE(buffer, offset) {95 return toBuffer(buffer).readFloatBE(offset)96}97 98function readFloatLE(buffer, offset) {99 return toBuffer(buffer).readFloatLE(offset)100}101 102function readInt32BE(buffer, offset) {103 return toBuffer(buffer).readInt32BE(offset)104}105 106function readInt32LE(buffer, offset) {107 return toBuffer(buffer).readInt32LE(offset)108}109 110function readUInt32BE(buffer, offset) {111 return toBuffer(buffer).readUInt32BE(offset)112}113 114function readUInt32LE(buffer, offset) {115 return toBuffer(buffer).readUInt32LE(offset)116}117 118function writeDoubleBE(buffer, value, offset) {119 return toBuffer(buffer).writeDoubleBE(value, offset)120}121 122function writeDoubleLE(buffer, value, offset) {123 return toBuffer(buffer).writeDoubleLE(value, offset)124}125 126function writeFloatBE(buffer, value, offset) {127 return toBuffer(buffer).writeFloatBE(value, offset)128}129 130function writeFloatLE(buffer, value, offset) {131 return toBuffer(buffer).writeFloatLE(value, offset)132}133 134function writeInt32BE(buffer, value, offset) {135 return toBuffer(buffer).writeInt32BE(value, offset)136}137 138function writeInt32LE(buffer, value, offset) {139 return toBuffer(buffer).writeInt32LE(value, offset)140}141 142function writeUInt32BE(buffer, value, offset) {143 return toBuffer(buffer).writeUInt32BE(value, offset)144}145 146function writeUInt32LE(buffer, value, offset) {147 return toBuffer(buffer).writeUInt32LE(value, offset)148}149 150module.exports = {151 isBuffer,152 isEncoding,153 alloc,154 allocUnsafe,155 allocUnsafeSlow,156 byteLength,157 compare,158 concat,159 copy,160 equals,161 fill,162 from,163 includes,164 indexOf,165 lastIndexOf,166 swap16,167 swap32,168 swap64,169 toBuffer,170 toString,171 write,172 readDoubleBE,173 readDoubleLE,174 readFloatBE,175 readFloatLE,176 readInt32BE,177 readInt32LE,178 readUInt32BE,179 readUInt32LE,180 writeDoubleBE,181 writeDoubleLE,182 writeFloatBE,183 writeFloatLE,184 writeInt32BE,185 writeInt32LE,186 writeUInt32BE,187 writeUInt32LE188}189 