bun
bun copied to clipboard
Implement Buffer swap16, swap32, swap64
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
andswap64
insrc/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
andswap64
respectively)
To do:
- [ ] Port node tests