Commit 1f8e4b54 authored by James M Snell's avatar James M Snell Committed by Evan Lucas
Browse files

buffer: add swap16() and swap32() methods

Adds Buffer.prototype.swap16() and Buffer.prototype.swap32()
methods that mutate the Buffer instance in-place by swapping the
16-bit and 32-bit byte-order.

Example:

```js
const buf = Buffer([0x1, 0x2, 0x3, 0x4]);
buf.swap16();
console.log(buf);
  // prints Buffer(0x2, 0x1, 0x4, 0x3);

buf.swap32();
console.log(buf);
  // prints Buffer(0x3, 0x4, 0x1, 0x2);
```

PR-URL: https://github.com/nodejs/node/pull/5724


Reviewed-By: default avatarTrevor Norris <trev.norris@gmail.com>
parent bdf933be
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment