bun icon indicating copy to clipboard operation
bun copied to clipboard

Implement Buffer swap16, swap32, swap64

Open malcolmstill opened this issue 2 years ago • 0 comments

The Buffer api is not complete as detailed in https://github.com/oven-sh/bun/issues/155.

Specifically swap16, swap32 and swap64 are unimplemented.

This PR:

  • Implements swap16, swap32 and swap64 in src/bun.js/bindings/JSBuffer.cpp
  • Adds supporting tests to test/bun.js/buffer.test.js, testing:
    • Correct swapping behaviour for several examples
    • An error is thrown if the buffers are not appropriately sized (not multiples of the swap byte size, i.e. 2, 4, or 8 bytes for swap16, swap32 and swap64 respectively)

To do:

  • [ ] Port node tests

malcolmstill avatar Dec 25 '22 01:12 malcolmstill