{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/node/issues/5724","repository_url":"https://api.github.com/repos/nodejs/node","labels_url":"https://api.github.com/repos/nodejs/node/issues/5724/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/node/issues/5724/comments","events_url":"https://api.github.com/repos/nodejs/node/issues/5724/events","html_url":"https://github.com/nodejs/node/pull/5724","id":141057032,"number":5724,"title":"buffer: add swap16() and swap32() methods","user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/nodejs/node/labels/buffer","name":"buffer","color":"f7c6c7"},{"url":"https://api.github.com/repos/nodejs/node/labels/semver-minor","name":"semver-minor","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2016-03-15T18:15:37Z","updated_at":"2016-03-18T18:23:10Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/nodejs/node/pulls/5724","html_url":"https://github.com/nodejs/node/pull/5724","diff_url":"https://github.com/nodejs/node/pull/5724.diff","patch_url":"https://github.com/nodejs/node/pull/5724.patch"},"body":"### Pull Request check-list\r\n\r\n- [x] Does `make -j8 test` (UNIX) or `vcbuild test nosign` (Windows) pass with\r\n  this change (including linting)?\r\n- [x] Is the commit message formatted according to [CONTRIBUTING.md][0]?\r\n- [ ] If this change fixes a bug (or a performance problem), is a regression\r\n  test (or a benchmark) included?\r\n- [x] Is a documentation update included (if this change modifies\r\n  existing APIs, or introduces new ones)?\r\n\r\n### Affected core subsystem(s)\r\n\r\nbuffer\r\n\r\n### Description of change\r\n\r\nAdds ~~Buffer.prototype.swapShort()~~ Buffer.prototype.swap16() and \r\n~~Buffer.prototype.swapLong()~~ Buffer.prototype.swap32() methods that \r\nmutate the Buffer instance in-place by swapping the 16-bit and 32-bit \r\nbyte-order.\r\n\r\nExample:\r\n\r\n```js\r\nconst buf = Buffer([0x1, 0x2, 0x3, 0x4]);\r\nbuf.swap16();\r\nconsole.log(buf);\r\n  // prints Buffer(0x2, 0x1, 0x4, 0x3);\r\n\r\nbuf.swap32();\r\nconsole.log(buf);\r\n  // prints Buffer(0x3, 0x4, 0x1, 0x2);\r\n```\r\n\r\nWas looking at a number of use cases recently around reading in UTF16BE data and converting that to UTF8 and realized that we really didn't expose an efficient mechanism for doing a byte-swap in Buffer. This seemed like a useful API addition.\r\n\r\n/cc @trevnorris @srl295 "},"comment":{"url":"https://api.github.com/repos/nodejs/node/issues/comments/198481724","html_url":"https://github.com/nodejs/node/pull/5724#issuecomment-198481724","issue_url":"https://api.github.com/repos/nodejs/node/issues/5724","id":198481724,"user":{"login":"jasnell","id":439929,"avatar_url":"https://avatars.githubusercontent.com/u/439929?v=3","gravatar_id":"","url":"https://api.github.com/users/jasnell","html_url":"https://github.com/jasnell","followers_url":"https://api.github.com/users/jasnell/followers","following_url":"https://api.github.com/users/jasnell/following{/other_user}","gists_url":"https://api.github.com/users/jasnell/gists{/gist_id}","starred_url":"https://api.github.com/users/jasnell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jasnell/subscriptions","organizations_url":"https://api.github.com/users/jasnell/orgs","repos_url":"https://api.github.com/users/jasnell/repos","events_url":"https://api.github.com/users/jasnell/events{/privacy}","received_events_url":"https://api.github.com/users/jasnell/received_events","type":"User","site_admin":false},"created_at":"2016-03-18T18:23:10Z","updated_at":"2016-03-18T18:23:10Z","body":"@ronkorving ... updated! PTAL (also made a couple other cleanups)"}}