{"action":"created","comment":{"url":"https://api.github.com/repos/resin-io/resin-image-write/pulls/comments/53054973","id":53054973,"diff_hunk":"@@ -0,0 +1,84 @@\n+\n+/*\n+Copyright 2016 Resin.io\n+\n+Licensed under the Apache License, Version 2.0 (the \"License\");\n+you may not use this file except in compliance with the License.\n+You may obtain a copy of the License at\n+\n+\t http://www.apache.org/licenses/LICENSE-2.0\n+\n+Unless required by applicable law or agreed to in writing, software\n+distributed under the License is distributed on an \"AS IS\" BASIS,\n+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+See the License for the specific language governing permissions and\n+limitations under the License.\n+ */\n+var CRC32Stream, Promise, SliceStream, _;\n+\n+CRC32Stream = require('crc32-stream');\n+\n+SliceStream = require('slice-stream');\n+\n+Promise = require('bluebird');\n+\n+_ = require('lodash');\n+\n+\n+/**\n+ * @summary Calculate stream checksum from stream\n+ * @function\n+ * @protected\n+ *\n+ * @description\n+ *\n+ * @param {ReadableStream} stream - stream\n+ * @param {Object} options - options\n+ * @param {Number} options.bytes - bytes to calculate the checksum for\n+ *\n+ * @fulfil {String} - checksum\n+ * @returns {Promise}\n+ *\n+ * @example\n+ *\n+ * checksum.calculate fs.createReadStream('/dev/rdisk2'),\n+ * \tbytes: 1024 * 100\n+ * .then (result) ->\n+ * \tconsole.log(result)\n+ */\n+\n+exports.calculate = function(stream, options) {\n+  if (options == null) {\n+    options = {};\n+  }\n+  return new Promise(function(resolve, reject) {\n+    var checksum, slice;\n+    if (options.bytes == null) {\n+      throw new Error('Missing bytes option');\n+    }\n+    if (_.any([!_.isNumber(options.bytes), _.isNaN(options.bytes), options.bytes <= 0])) {\n+      throw new Error(\"Invalid bytes option: \" + options.bytes);","path":"build/checksum.js","position":60,"original_position":60,"commit_id":"5472ef8f1bc5a0150e32cd5fdc2535fad1ce311e","original_commit_id":"5472ef8f1bc5a0150e32cd5fdc2535fad1ce311e","user":{"login":"houndci-bot","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Mixed double and single quotes.","created_at":"2016-02-16T18:30:50Z","updated_at":"2016-02-16T18:30:50Z","html_url":"https://github.com/resin-io/resin-image-write/pull/16#discussion_r53054973","pull_request_url":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16","_links":{"self":{"href":"https://api.github.com/repos/resin-io/resin-image-write/pulls/comments/53054973"},"html":{"href":"https://github.com/resin-io/resin-image-write/pull/16#discussion_r53054973"},"pull_request":{"href":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16"}}},"pull_request":{"url":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16","id":59401572,"html_url":"https://github.com/resin-io/resin-image-write/pull/16","diff_url":"https://github.com/resin-io/resin-image-write/pull/16.diff","patch_url":"https://github.com/resin-io/resin-image-write/pull/16.patch","issue_url":"https://api.github.com/repos/resin-io/resin-image-write/issues/16","number":16,"state":"open","locked":false,"title":"Implement a way to check if a write was successful","user":{"login":"jviotti","id":2192773,"avatar_url":"https://avatars.githubusercontent.com/u/2192773?v=3","gravatar_id":"","url":"https://api.github.com/users/jviotti","html_url":"https://github.com/jviotti","followers_url":"https://api.github.com/users/jviotti/followers","following_url":"https://api.github.com/users/jviotti/following{/other_user}","gists_url":"https://api.github.com/users/jviotti/gists{/gist_id}","starred_url":"https://api.github.com/users/jviotti/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jviotti/subscriptions","organizations_url":"https://api.github.com/users/jviotti/orgs","repos_url":"https://api.github.com/users/jviotti/repos","events_url":"https://api.github.com/users/jviotti/events{/privacy}","received_events_url":"https://api.github.com/users/jviotti/received_events","type":"User","site_admin":false},"body":null,"created_at":"2016-02-15T18:54:14Z","updated_at":"2016-02-16T18:30:51Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3eac7de60ce9c4febb6ac6a59a6eca31122bb330","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16/commits","review_comments_url":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16/comments","review_comment_url":"https://api.github.com/repos/resin-io/resin-image-write/pulls/comments{/number}","comments_url":"https://api.github.com/repos/resin-io/resin-image-write/issues/16/comments","statuses_url":"https://api.github.com/repos/resin-io/resin-image-write/statuses/5472ef8f1bc5a0150e32cd5fdc2535fad1ce311e","head":{"label":"resin-io:feat/integrity-check","ref":"feat/integrity-check","sha":"5472ef8f1bc5a0150e32cd5fdc2535fad1ce311e","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":38319391,"name":"resin-image-write","full_name":"resin-io/resin-image-write","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/resin-image-write","description":"Write a Resin.io image to a device.","fork":false,"url":"https://api.github.com/repos/resin-io/resin-image-write","forks_url":"https://api.github.com/repos/resin-io/resin-image-write/forks","keys_url":"https://api.github.com/repos/resin-io/resin-image-write/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/resin-image-write/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/resin-image-write/teams","hooks_url":"https://api.github.com/repos/resin-io/resin-image-write/hooks","issue_events_url":"https://api.github.com/repos/resin-io/resin-image-write/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/resin-image-write/events","assignees_url":"https://api.github.com/repos/resin-io/resin-image-write/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/resin-image-write/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/resin-image-write/tags","blobs_url":"https://api.github.com/repos/resin-io/resin-image-write/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/resin-image-write/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/resin-image-write/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/resin-image-write/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/resin-image-write/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/resin-image-write/languages","stargazers_url":"https://api.github.com/repos/resin-io/resin-image-write/stargazers","contributors_url":"https://api.github.com/repos/resin-io/resin-image-write/contributors","subscribers_url":"https://api.github.com/repos/resin-io/resin-image-write/subscribers","subscription_url":"https://api.github.com/repos/resin-io/resin-image-write/subscription","commits_url":"https://api.github.com/repos/resin-io/resin-image-write/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/resin-image-write/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/resin-image-write/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/resin-image-write/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/resin-image-write/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/resin-image-write/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/resin-image-write/merges","archive_url":"https://api.github.com/repos/resin-io/resin-image-write/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/resin-image-write/downloads","issues_url":"https://api.github.com/repos/resin-io/resin-image-write/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/resin-image-write/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/resin-image-write/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/resin-image-write/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/resin-image-write/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/resin-image-write/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/resin-image-write/deployments","created_at":"2015-06-30T16:08:45Z","updated_at":"2016-01-11T19:45:12Z","pushed_at":"2016-02-16T18:29:58Z","git_url":"git://github.com/resin-io/resin-image-write.git","ssh_url":"git@github.com:resin-io/resin-image-write.git","clone_url":"https://github.com/resin-io/resin-image-write.git","svn_url":"https://github.com/resin-io/resin-image-write","homepage":null,"size":17464,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"resin-io:master","ref":"master","sha":"471b553e8b855d6ac0a07419e63a978dfa220919","user":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"repo":{"id":38319391,"name":"resin-image-write","full_name":"resin-io/resin-image-write","owner":{"login":"resin-io","id":6157842,"avatar_url":"https://avatars.githubusercontent.com/u/6157842?v=3","gravatar_id":"","url":"https://api.github.com/users/resin-io","html_url":"https://github.com/resin-io","followers_url":"https://api.github.com/users/resin-io/followers","following_url":"https://api.github.com/users/resin-io/following{/other_user}","gists_url":"https://api.github.com/users/resin-io/gists{/gist_id}","starred_url":"https://api.github.com/users/resin-io/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/resin-io/subscriptions","organizations_url":"https://api.github.com/users/resin-io/orgs","repos_url":"https://api.github.com/users/resin-io/repos","events_url":"https://api.github.com/users/resin-io/events{/privacy}","received_events_url":"https://api.github.com/users/resin-io/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/resin-io/resin-image-write","description":"Write a Resin.io image to a device.","fork":false,"url":"https://api.github.com/repos/resin-io/resin-image-write","forks_url":"https://api.github.com/repos/resin-io/resin-image-write/forks","keys_url":"https://api.github.com/repos/resin-io/resin-image-write/keys{/key_id}","collaborators_url":"https://api.github.com/repos/resin-io/resin-image-write/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/resin-io/resin-image-write/teams","hooks_url":"https://api.github.com/repos/resin-io/resin-image-write/hooks","issue_events_url":"https://api.github.com/repos/resin-io/resin-image-write/issues/events{/number}","events_url":"https://api.github.com/repos/resin-io/resin-image-write/events","assignees_url":"https://api.github.com/repos/resin-io/resin-image-write/assignees{/user}","branches_url":"https://api.github.com/repos/resin-io/resin-image-write/branches{/branch}","tags_url":"https://api.github.com/repos/resin-io/resin-image-write/tags","blobs_url":"https://api.github.com/repos/resin-io/resin-image-write/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/resin-io/resin-image-write/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/resin-io/resin-image-write/git/refs{/sha}","trees_url":"https://api.github.com/repos/resin-io/resin-image-write/git/trees{/sha}","statuses_url":"https://api.github.com/repos/resin-io/resin-image-write/statuses/{sha}","languages_url":"https://api.github.com/repos/resin-io/resin-image-write/languages","stargazers_url":"https://api.github.com/repos/resin-io/resin-image-write/stargazers","contributors_url":"https://api.github.com/repos/resin-io/resin-image-write/contributors","subscribers_url":"https://api.github.com/repos/resin-io/resin-image-write/subscribers","subscription_url":"https://api.github.com/repos/resin-io/resin-image-write/subscription","commits_url":"https://api.github.com/repos/resin-io/resin-image-write/commits{/sha}","git_commits_url":"https://api.github.com/repos/resin-io/resin-image-write/git/commits{/sha}","comments_url":"https://api.github.com/repos/resin-io/resin-image-write/comments{/number}","issue_comment_url":"https://api.github.com/repos/resin-io/resin-image-write/issues/comments{/number}","contents_url":"https://api.github.com/repos/resin-io/resin-image-write/contents/{+path}","compare_url":"https://api.github.com/repos/resin-io/resin-image-write/compare/{base}...{head}","merges_url":"https://api.github.com/repos/resin-io/resin-image-write/merges","archive_url":"https://api.github.com/repos/resin-io/resin-image-write/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/resin-io/resin-image-write/downloads","issues_url":"https://api.github.com/repos/resin-io/resin-image-write/issues{/number}","pulls_url":"https://api.github.com/repos/resin-io/resin-image-write/pulls{/number}","milestones_url":"https://api.github.com/repos/resin-io/resin-image-write/milestones{/number}","notifications_url":"https://api.github.com/repos/resin-io/resin-image-write/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/resin-io/resin-image-write/labels{/name}","releases_url":"https://api.github.com/repos/resin-io/resin-image-write/releases{/id}","deployments_url":"https://api.github.com/repos/resin-io/resin-image-write/deployments","created_at":"2015-06-30T16:08:45Z","updated_at":"2016-01-11T19:45:12Z","pushed_at":"2016-02-16T18:29:58Z","git_url":"git://github.com/resin-io/resin-image-write.git","ssh_url":"git@github.com:resin-io/resin-image-write.git","clone_url":"https://github.com/resin-io/resin-image-write.git","svn_url":"https://github.com/resin-io/resin-image-write","homepage":null,"size":17464,"stargazers_count":0,"watchers_count":0,"language":"CoffeeScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16"},"html":{"href":"https://github.com/resin-io/resin-image-write/pull/16"},"issue":{"href":"https://api.github.com/repos/resin-io/resin-image-write/issues/16"},"comments":{"href":"https://api.github.com/repos/resin-io/resin-image-write/issues/16/comments"},"review_comments":{"href":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16/comments"},"review_comment":{"href":"https://api.github.com/repos/resin-io/resin-image-write/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/resin-io/resin-image-write/pulls/16/commits"},"statuses":{"href":"https://api.github.com/repos/resin-io/resin-image-write/statuses/5472ef8f1bc5a0150e32cd5fdc2535fad1ce311e"}}}}