buffer-helpers.js 649 B

12345678910111213141516171819202122
  1. module.exports = {
  2. readUInt32BE: function readUInt32BE(buf, offset) {
  3. return buf[offset++] * 16777216
  4. + buf[offset++] * 65536
  5. + buf[offset++] * 256
  6. + buf[offset];
  7. },
  8. writeUInt32BE: function writeUInt32BE(buf, value, offset) {
  9. buf[offset++] = (value >>> 24);
  10. buf[offset++] = (value >>> 16);
  11. buf[offset++] = (value >>> 8);
  12. buf[offset++] = value;
  13. return offset;
  14. },
  15. writeUInt32LE: function writeUInt32LE(buf, value, offset) {
  16. buf[offset++] = value;
  17. buf[offset++] = (value >>> 8);
  18. buf[offset++] = (value >>> 16);
  19. buf[offset++] = (value >>> 24);
  20. return offset;
  21. }
  22. };