{"action":"created","issue":{"url":"https://api.github.com/repos/kawanet/msgpack-lite/issues/38","repository_url":"https://api.github.com/repos/kawanet/msgpack-lite","labels_url":"https://api.github.com/repos/kawanet/msgpack-lite/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/kawanet/msgpack-lite/issues/38/comments","events_url":"https://api.github.com/repos/kawanet/msgpack-lite/issues/38/events","html_url":"https://github.com/kawanet/msgpack-lite/issues/38","id":157670206,"number":38,"title":"Support encoding ArrayBuffer as plain bytes","user":{"login":"dbrgn","id":105168,"avatar_url":"https://avatars.githubusercontent.com/u/105168?v=3","gravatar_id":"","url":"https://api.github.com/users/dbrgn","html_url":"https://github.com/dbrgn","followers_url":"https://api.github.com/users/dbrgn/followers","following_url":"https://api.github.com/users/dbrgn/following{/other_user}","gists_url":"https://api.github.com/users/dbrgn/gists{/gist_id}","starred_url":"https://api.github.com/users/dbrgn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbrgn/subscriptions","organizations_url":"https://api.github.com/users/dbrgn/orgs","repos_url":"https://api.github.com/users/dbrgn/repos","events_url":"https://api.github.com/users/dbrgn/events{/privacy}","received_events_url":"https://api.github.com/users/dbrgn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-31T13:22:29Z","updated_at":"2016-06-13T10:01:17Z","closed_at":null,"body":"Right now, typed arrays and array buffers (e.g. `Uint8Array`) will be encoded using extension types (e.g. 0x11).\r\n\r\n```\r\n> msgpack.encode(new Uint8Array([0x01, 0x02, 0x03]))\r\n< [199, 3, 18, 1, 2, 3]\r\n```\r\n\r\nI'm working with a lot of typed arrays in my application. If I want to send plain arrays to the server, I need to convert those to an `Array`:\r\n\r\n```\r\n> msgpack.encode(Array.from(new Uint8Array([0x01, 0x02, 0x03])))\r\n< [147, 1, 2, 3]\r\n```\r\n\r\nSending binary data directly doesn't even seem to be possible in a browser environment without the `Buffer` library.\r\n\r\nI'm pretty sure that this results in a new allocation and a copy of the typed array to the untyped array. In a performance critical application, that might be quite expensive... (Note: I'm only guessing here about the allocation and don't know how to verify the claim...)\r\n\r\nIf that assumption is true, might it be possible to introduce an encoding mode where an `ArrayBuffer` is serialized to the msgpack binary format directly? Or is it possible to solve that problem using a codec?\r\n\r\nIf that were possible, then efficient serialization would be possible:\r\n\r\n```\r\n> let array = new Uint8Array([0x01, 0x02, 0x03]);\r\n> msgpack.encode(array.buffer, simplify=True)\r\n< [196, 3, 1, 2, 3]\r\n```"},"comment":{"url":"https://api.github.com/repos/kawanet/msgpack-lite/issues/comments/225539095","html_url":"https://github.com/kawanet/msgpack-lite/issues/38#issuecomment-225539095","issue_url":"https://api.github.com/repos/kawanet/msgpack-lite/issues/38","id":225539095,"user":{"login":"dbrgn","id":105168,"avatar_url":"https://avatars.githubusercontent.com/u/105168?v=3","gravatar_id":"","url":"https://api.github.com/users/dbrgn","html_url":"https://github.com/dbrgn","followers_url":"https://api.github.com/users/dbrgn/followers","following_url":"https://api.github.com/users/dbrgn/following{/other_user}","gists_url":"https://api.github.com/users/dbrgn/gists{/gist_id}","starred_url":"https://api.github.com/users/dbrgn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dbrgn/subscriptions","organizations_url":"https://api.github.com/users/dbrgn/orgs","repos_url":"https://api.github.com/users/dbrgn/repos","events_url":"https://api.github.com/users/dbrgn/events{/privacy}","received_events_url":"https://api.github.com/users/dbrgn/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T10:01:17Z","updated_at":"2016-06-13T10:01:17Z","body":"Seems to work properly, thanks!"}}
{"actor":{"display_login":"dbrgn"}}