{"action":"created","comment":{"url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/comments/231689919","pull_request_review_id":172715790,"id":231689919,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzMTY4OTkxOQ==","diff_hunk":"@@ -1,49 +1,57 @@\n-import {\n-  loadUnsafeWithOffset,\n-} from \"./internal/arraybuffer\";\n+import { HEADER_SIZE } from \"./internal/arraybuffer\";\n+\n+@inline\n+function get<T> (buffer: ArrayBuffer, byteOffset: i32, littleEndian: boolean): T {\n+  const result = load<T>(changetype<usize>(buffer) + byteOffset, HEADER_SIZE);\n+  return littleEndian ? result : bswap<T>(result);\n+}\n \n export class DataView {\n-  readonly buffer: ArrayBuffer;\n-  readonly byteOffset: i32;\n-  readonly byteLength: i32;\n-\n-  constructor (buffer: ArrayBuffer, byteOffset: i32, byteLength: i32) {\n-    this.buffer = buffer\n-    this.byteOffset = byteOffset\n-    this.byteLength = byteLength\n-  }\n-\n-  @inline\n-  getUint32 (byteOffset: u32, littleEndian: boolean): u32 {\n-    if (littleEndian) {\n-      return (\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 0, this.byteOffset) << 24) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 1, this.byteOffset) << 16) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 2, this.byteOffset) << 8) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 3, this.byteOffset) << 0)\n-      );\n-    } else {\n-      return (\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 0, this.byteOffset) << 0) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 1, this.byteOffset) << 8) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 2, this.byteOffset) << 16) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 3, this.byteOffset) << 24)\n-      );\n-    }\n-  }\n-\n-  @inline\n-  getUint16 (byteOffset: u32, littleEndian: boolean): u16 {\n-    if (littleEndian) {\n-      return (\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 0, this.byteOffset) << 8) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 1, this.byteOffset) << 0)\n-      );\n-    } else {\n-      return (\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 0, this.byteOffset) << 0) &\n-        (loadUnsafeWithOffset<u8, u8>(this.buffer, byteOffset + 1, this.byteOffset) << 8)\n-      );\n-    }\n+  constructor(\n+    readonly buffer: ArrayBuffer,\n+    readonly byteOffset: i32 = 0,\n+    readonly byteLength: i32 = i32.MAX_VALUE,\n+  ) {\n+    this.byteLength = min(buffer.byteLength, byteLength);","path":"std/assembly/dataview.ts","position":21,"original_position":60,"commit_id":"463f2bd7884e7207c5841396df66713d16c61d3c","original_commit_id":"a786204f995e7b731c5a0ffd38d22d48f8c52062","user":{"login":"dcodeIO","id":1136893,"node_id":"MDQ6VXNlcjExMzY4OTM=","avatar_url":"https://avatars0.githubusercontent.com/u/1136893?v=4","gravatar_id":"","url":"https://api.github.com/users/dcodeIO","html_url":"https://github.com/dcodeIO","followers_url":"https://api.github.com/users/dcodeIO/followers","following_url":"https://api.github.com/users/dcodeIO/following{/other_user}","gists_url":"https://api.github.com/users/dcodeIO/gists{/gist_id}","starred_url":"https://api.github.com/users/dcodeIO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dcodeIO/subscriptions","organizations_url":"https://api.github.com/users/dcodeIO/orgs","repos_url":"https://api.github.com/users/dcodeIO/repos","events_url":"https://api.github.com/users/dcodeIO/events{/privacy}","received_events_url":"https://api.github.com/users/dcodeIO/received_events","type":"User","site_admin":false},"body":"Should also take care of negative values I think. What happens n JS if a negative value is provided?","created_at":"2018-11-07T21:49:05Z","updated_at":"2018-11-07T21:49:06Z","html_url":"https://github.com/AssemblyScript/assemblyscript/pull/316#discussion_r231689919","pull_request_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/comments/231689919"},"html":{"href":"https://github.com/AssemblyScript/assemblyscript/pull/316#discussion_r231689919"},"pull_request":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316"}}},"pull_request":{"url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316","id":229127099,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI5MTI3MDk5","html_url":"https://github.com/AssemblyScript/assemblyscript/pull/316","diff_url":"https://github.com/AssemblyScript/assemblyscript/pull/316.diff","patch_url":"https://github.com/AssemblyScript/assemblyscript/pull/316.patch","issue_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/316","number":316,"state":"open","locked":false,"title":"[WIP] Add DataView to standard library","user":{"login":"LinusU","id":189580,"node_id":"MDQ6VXNlcjE4OTU4MA==","avatar_url":"https://avatars0.githubusercontent.com/u/189580?v=4","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"body":"Opening this for early feedback, as soon as I know I'm on the right track it should be very easy for me to add all the required methods.\r\n\r\nSome questions:\r\n\r\n1. Should I just `throw new RangeError('Out of bounds access')` when trying to access outside the bounds?\r\n1. Is there any way to overload the `get*` functions for when `littleEndian` is known at compile time, or will the compiler just figure it out anyway?\r\n\r\n    e.g. something like this:\r\n\r\n    ```ts\r\n    function getUint32(offset: number, littleEndian: false) { ... }\r\n    function getUint32(offset: number, littleEndian: true) { ... }\r\n    function getUint32(offset: number, littleEndian: boolean) { ... }\r\n    ```\r\n1. Do I have to register `DataView` as a global variable somewhere?\r\n1. Where do I put the tests? I'm assuming somewhere under `tests/`, but then I'm a bit lost ☺️ \r\n\r\nThank you for your time, looking forward to working a lot more on this project, it rocks! 🙌 \r\n\r\nfixes #315 \r\n\r\nFIXME:\r\n\r\n- [ ] Don't commit `dist/*` files\r\n- [x] Add me to `NOTICE` file","created_at":"2018-11-07T18:34:19Z","updated_at":"2018-11-07T21:49:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26c8ef2bf6e6be50e6fae8672ee0fbe40a53da45","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316/commits","review_comments_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316/comments","review_comment_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/comments{/number}","comments_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/316/comments","statuses_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/statuses/463f2bd7884e7207c5841396df66713d16c61d3c","head":{"label":"LinusU:dataview","ref":"dataview","sha":"463f2bd7884e7207c5841396df66713d16c61d3c","user":{"login":"LinusU","id":189580,"node_id":"MDQ6VXNlcjE4OTU4MA==","avatar_url":"https://avatars0.githubusercontent.com/u/189580?v=4","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"repo":{"id":156586576,"node_id":"MDEwOlJlcG9zaXRvcnkxNTY1ODY1NzY=","name":"assemblyscript","full_name":"LinusU/assemblyscript","private":false,"owner":{"login":"LinusU","id":189580,"node_id":"MDQ6VXNlcjE4OTU4MA==","avatar_url":"https://avatars0.githubusercontent.com/u/189580?v=4","gravatar_id":"","url":"https://api.github.com/users/LinusU","html_url":"https://github.com/LinusU","followers_url":"https://api.github.com/users/LinusU/followers","following_url":"https://api.github.com/users/LinusU/following{/other_user}","gists_url":"https://api.github.com/users/LinusU/gists{/gist_id}","starred_url":"https://api.github.com/users/LinusU/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LinusU/subscriptions","organizations_url":"https://api.github.com/users/LinusU/orgs","repos_url":"https://api.github.com/users/LinusU/repos","events_url":"https://api.github.com/users/LinusU/events{/privacy}","received_events_url":"https://api.github.com/users/LinusU/received_events","type":"User","site_admin":false},"html_url":"https://github.com/LinusU/assemblyscript","description":"A TypeScript to WebAssembly compiler 🚀","fork":true,"url":"https://api.github.com/repos/LinusU/assemblyscript","forks_url":"https://api.github.com/repos/LinusU/assemblyscript/forks","keys_url":"https://api.github.com/repos/LinusU/assemblyscript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LinusU/assemblyscript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LinusU/assemblyscript/teams","hooks_url":"https://api.github.com/repos/LinusU/assemblyscript/hooks","issue_events_url":"https://api.github.com/repos/LinusU/assemblyscript/issues/events{/number}","events_url":"https://api.github.com/repos/LinusU/assemblyscript/events","assignees_url":"https://api.github.com/repos/LinusU/assemblyscript/assignees{/user}","branches_url":"https://api.github.com/repos/LinusU/assemblyscript/branches{/branch}","tags_url":"https://api.github.com/repos/LinusU/assemblyscript/tags","blobs_url":"https://api.github.com/repos/LinusU/assemblyscript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LinusU/assemblyscript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LinusU/assemblyscript/git/refs{/sha}","trees_url":"https://api.github.com/repos/LinusU/assemblyscript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LinusU/assemblyscript/statuses/{sha}","languages_url":"https://api.github.com/repos/LinusU/assemblyscript/languages","stargazers_url":"https://api.github.com/repos/LinusU/assemblyscript/stargazers","contributors_url":"https://api.github.com/repos/LinusU/assemblyscript/contributors","subscribers_url":"https://api.github.com/repos/LinusU/assemblyscript/subscribers","subscription_url":"https://api.github.com/repos/LinusU/assemblyscript/subscription","commits_url":"https://api.github.com/repos/LinusU/assemblyscript/commits{/sha}","git_commits_url":"https://api.github.com/repos/LinusU/assemblyscript/git/commits{/sha}","comments_url":"https://api.github.com/repos/LinusU/assemblyscript/comments{/number}","issue_comment_url":"https://api.github.com/repos/LinusU/assemblyscript/issues/comments{/number}","contents_url":"https://api.github.com/repos/LinusU/assemblyscript/contents/{+path}","compare_url":"https://api.github.com/repos/LinusU/assemblyscript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LinusU/assemblyscript/merges","archive_url":"https://api.github.com/repos/LinusU/assemblyscript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LinusU/assemblyscript/downloads","issues_url":"https://api.github.com/repos/LinusU/assemblyscript/issues{/number}","pulls_url":"https://api.github.com/repos/LinusU/assemblyscript/pulls{/number}","milestones_url":"https://api.github.com/repos/LinusU/assemblyscript/milestones{/number}","notifications_url":"https://api.github.com/repos/LinusU/assemblyscript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LinusU/assemblyscript/labels{/name}","releases_url":"https://api.github.com/repos/LinusU/assemblyscript/releases{/id}","deployments_url":"https://api.github.com/repos/LinusU/assemblyscript/deployments","created_at":"2018-11-07T17:52:12Z","updated_at":"2018-11-07T19:45:31Z","pushed_at":"2018-11-07T20:24:34Z","git_url":"git://github.com/LinusU/assemblyscript.git","ssh_url":"git@github.com:LinusU/assemblyscript.git","clone_url":"https://github.com/LinusU/assemblyscript.git","svn_url":"https://github.com/LinusU/assemblyscript","homepage":"https://assemblyscript.org","size":30192,"stargazers_count":0,"watchers_count":0,"language":"WebAssembly","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"AssemblyScript:master","ref":"master","sha":"ef3b47d91cfce603f570976f555ff5434fa069f0","user":{"login":"AssemblyScript","id":28916798,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTE2Nzk4","avatar_url":"https://avatars3.githubusercontent.com/u/28916798?v=4","gravatar_id":"","url":"https://api.github.com/users/AssemblyScript","html_url":"https://github.com/AssemblyScript","followers_url":"https://api.github.com/users/AssemblyScript/followers","following_url":"https://api.github.com/users/AssemblyScript/following{/other_user}","gists_url":"https://api.github.com/users/AssemblyScript/gists{/gist_id}","starred_url":"https://api.github.com/users/AssemblyScript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AssemblyScript/subscriptions","organizations_url":"https://api.github.com/users/AssemblyScript/orgs","repos_url":"https://api.github.com/users/AssemblyScript/repos","events_url":"https://api.github.com/users/AssemblyScript/events{/privacy}","received_events_url":"https://api.github.com/users/AssemblyScript/received_events","type":"Organization","site_admin":false},"repo":{"id":105138356,"node_id":"MDEwOlJlcG9zaXRvcnkxMDUxMzgzNTY=","name":"assemblyscript","full_name":"AssemblyScript/assemblyscript","private":false,"owner":{"login":"AssemblyScript","id":28916798,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI4OTE2Nzk4","avatar_url":"https://avatars3.githubusercontent.com/u/28916798?v=4","gravatar_id":"","url":"https://api.github.com/users/AssemblyScript","html_url":"https://github.com/AssemblyScript","followers_url":"https://api.github.com/users/AssemblyScript/followers","following_url":"https://api.github.com/users/AssemblyScript/following{/other_user}","gists_url":"https://api.github.com/users/AssemblyScript/gists{/gist_id}","starred_url":"https://api.github.com/users/AssemblyScript/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AssemblyScript/subscriptions","organizations_url":"https://api.github.com/users/AssemblyScript/orgs","repos_url":"https://api.github.com/users/AssemblyScript/repos","events_url":"https://api.github.com/users/AssemblyScript/events{/privacy}","received_events_url":"https://api.github.com/users/AssemblyScript/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/AssemblyScript/assemblyscript","description":"A TypeScript to WebAssembly compiler 🚀","fork":false,"url":"https://api.github.com/repos/AssemblyScript/assemblyscript","forks_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/forks","keys_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/teams","hooks_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/hooks","issue_events_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/events{/number}","events_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/events","assignees_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/assignees{/user}","branches_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/branches{/branch}","tags_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/tags","blobs_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/git/refs{/sha}","trees_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/statuses/{sha}","languages_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/languages","stargazers_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/stargazers","contributors_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/contributors","subscribers_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/subscribers","subscription_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/subscription","commits_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/commits{/sha}","git_commits_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/git/commits{/sha}","comments_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/comments{/number}","issue_comment_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/comments{/number}","contents_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/contents/{+path}","compare_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/merges","archive_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/downloads","issues_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues{/number}","pulls_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls{/number}","milestones_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/milestones{/number}","notifications_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/labels{/name}","releases_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/releases{/id}","deployments_url":"https://api.github.com/repos/AssemblyScript/assemblyscript/deployments","created_at":"2017-09-28T11:06:50Z","updated_at":"2018-11-07T19:44:43Z","pushed_at":"2018-11-07T20:50:04Z","git_url":"git://github.com/AssemblyScript/assemblyscript.git","ssh_url":"git@github.com:AssemblyScript/assemblyscript.git","clone_url":"https://github.com/AssemblyScript/assemblyscript.git","svn_url":"https://github.com/AssemblyScript/assemblyscript","homepage":"https://assemblyscript.org","size":30035,"stargazers_count":2852,"watchers_count":2852,"language":"WebAssembly","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":118,"mirror_url":null,"archived":false,"open_issues_count":84,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":118,"open_issues":84,"watchers":2852,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316"},"html":{"href":"https://github.com/AssemblyScript/assemblyscript/pull/316"},"issue":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/316"},"comments":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/issues/316/comments"},"review_comments":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316/comments"},"review_comment":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/pulls/316/commits"},"statuses":{"href":"https://api.github.com/repos/AssemblyScript/assemblyscript/statuses/463f2bd7884e7207c5841396df66713d16c61d3c"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"dcodeIO"}}