{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/pbf/issues/35","repository_url":"https://api.github.com/repos/mapbox/pbf","labels_url":"https://api.github.com/repos/mapbox/pbf/issues/35/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/pbf/issues/35/comments","events_url":"https://api.github.com/repos/mapbox/pbf/issues/35/events","html_url":"https://github.com/mapbox/pbf/issues/35","id":154779575,"number":35,"title":"Replace buffer implementation with standard Uint8Array","user":{"login":"jfirebaugh","id":98601,"avatar_url":"https://avatars.githubusercontent.com/u/98601?v=3","gravatar_id":"","url":"https://api.github.com/users/jfirebaugh","html_url":"https://github.com/jfirebaugh","followers_url":"https://api.github.com/users/jfirebaugh/followers","following_url":"https://api.github.com/users/jfirebaugh/following{/other_user}","gists_url":"https://api.github.com/users/jfirebaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/jfirebaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfirebaugh/subscriptions","organizations_url":"https://api.github.com/users/jfirebaugh/orgs","repos_url":"https://api.github.com/users/jfirebaugh/repos","events_url":"https://api.github.com/users/jfirebaugh/events{/privacy}","received_events_url":"https://api.github.com/users/jfirebaugh/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/mapbox/pbf/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2016-05-13T19:03:33Z","updated_at":"2016-08-24T22:05:26Z","closed_at":null,"body":"The conditional use of node's `Buffer` versus a shim based on `Uint8Array` leads to subtle incompatibilities between node and the browser. I just spent a couple hours debugging an issue in mapbox-gl-js that stems from the following difference:\r\n\r\n```js\r\nvar Pbf = require('pbf');\r\nvar pbf = new Pbf();\r\npbf.writeVarint(0);\r\nconsole.log(pbf.finish().buffer.byteLength);\r\n```\r\n\r\nIn the browser, this prints 16, as expected. In node, it prints 8192.\r\n\r\nTo eliminate this gotcha, pbf should use standard `Uint8Array`'s everywhere, and drop usage of `Buffer`."},"comment":{"url":"https://api.github.com/repos/mapbox/pbf/issues/comments/242223154","html_url":"https://github.com/mapbox/pbf/issues/35#issuecomment-242223154","issue_url":"https://api.github.com/repos/mapbox/pbf/issues/35","id":242223154,"user":{"login":"jfirebaugh","id":98601,"avatar_url":"https://avatars.githubusercontent.com/u/98601?v=3","gravatar_id":"","url":"https://api.github.com/users/jfirebaugh","html_url":"https://github.com/jfirebaugh","followers_url":"https://api.github.com/users/jfirebaugh/followers","following_url":"https://api.github.com/users/jfirebaugh/following{/other_user}","gists_url":"https://api.github.com/users/jfirebaugh/gists{/gist_id}","starred_url":"https://api.github.com/users/jfirebaugh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jfirebaugh/subscriptions","organizations_url":"https://api.github.com/users/jfirebaugh/orgs","repos_url":"https://api.github.com/users/jfirebaugh/repos","events_url":"https://api.github.com/users/jfirebaugh/events{/privacy}","received_events_url":"https://api.github.com/users/jfirebaugh/received_events","type":"User","site_admin":false},"created_at":"2016-08-24T22:05:26Z","updated_at":"2016-08-24T22:05:26Z","body":"I still think we should just use and accept the performance of `Uint8Array`.\r\n\r\nThe current code forces copying the data in the browser when you do `new Pbf(uint8Array)`."}}
{"actor":{"display_login":"jfirebaugh"}}