{"action":"created","comment":{"url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/comments/43406728","id":43406728,"diff_hunk":"@@ -380,61 +369,62 @@ Macaroon.prototype.addCaveat = function(caveatId, verificationId, loc) {\n //\n // Verify throws an exception if the verification fails.\n Macaroon.prototype.verify = function(rootKey, check, discharges) {\n-\trootKey = makeKey(rootKey)\n+\trootKey = makeKey(rootKey);\n \tvar used = [];\n \tvar i;\n-\tfor(i in discharges){\n-\t\tused[i] = 0;\n+\tdischarges = discharges || [];\n+\tfor (i = 0; i < discharges.length; i++) {\n+    used[i] = 0;\n \t}\n \tthis._verify(this._signature, rootKey, check, discharges, used);\n-\tfor(i in discharges){\n-\t\tvar dm = discharges[i];\n-\t\tif(used[i] === 0){\n-\t\t\tthrow new Error(\"discharge macaroon \" + quote(dm.id()) + \" was not used\");\n+\tdischarges.forEach(function(dm, i) {\n+\t\tif (used[i] === 0) {\n+\t\t\tthrow new Error('discharge macaroon ' + quote(dm.id()) + ' was not used');\n \t\t}\n-\t\tif(used[i] !== 1){\n+\t\tif (used[i] !== 1) {\n \t\t\t// Should be impossible because of check in verify1, but be defensive.\n-\t\t\tthrow new Error(\"discharge macaroon \" + quote(dm.id()) + \" was used more than once\");\n+\t\t\tthrow new Error('discharge macaroon ' + quote(dm.id()) + ' was used more than once');\n \t\t}\n-\t}\n+\t});\n };\n \n Macaroon.prototype._verify = function(rootSig, rootKey, check, discharges, used) {\n \tvar caveatSig = keyedHash(rootKey,  sjcl.codec.utf8String.toBits(this.id()));\n \tvar i, di;\n-\tfor(i in this._caveats){\n-\t\tvar cav = this._caveats[i];\n-\t\tif(cav._vid !== null){\n+\tthis._caveats.forEach(function(cav) {\n+\t\tif (cav._vid !== null) {\n \t\t\tvar cavKey = decrypt(caveatSig, cav._vid);\n \t\t\tvar found = false;\n-\t\t\tfor(di in discharges){\n-\t\t\t\tvar dm = discharges[di];\n-\t\t\t\tif(dm.id() !== cav._identifier) {\n+\t\t\tvar di, dm;","path":"macaroon.js","position":358,"original_position":358,"commit_id":"2ccc492ed1a3f2da4d95b7689c5aa552ab5ad975","original_commit_id":"2ccc492ed1a3f2da4d95b7689c5aa552ab5ad975","user":{"login":"rogpeppe","id":66491,"avatar_url":"https://avatars.githubusercontent.com/u/66491?v=3","gravatar_id":"","url":"https://api.github.com/users/rogpeppe","html_url":"https://github.com/rogpeppe","followers_url":"https://api.github.com/users/rogpeppe/followers","following_url":"https://api.github.com/users/rogpeppe/following{/other_user}","gists_url":"https://api.github.com/users/rogpeppe/gists{/gist_id}","starred_url":"https://api.github.com/users/rogpeppe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rogpeppe/subscriptions","organizations_url":"https://api.github.com/users/rogpeppe/orgs","repos_url":"https://api.github.com/users/rogpeppe/repos","events_url":"https://api.github.com/users/rogpeppe/events{/privacy}","received_events_url":"https://api.github.com/users/rogpeppe/received_events","type":"User","site_admin":false},"body":"Shouldn't these vars be at the top level of the function, or is it considered OK in this case with a single if?","created_at":"2015-10-29T16:13:17Z","updated_at":"2015-10-29T16:13:17Z","html_url":"https://github.com/go-macaroon/js-macaroon/pull/7#discussion_r43406728","pull_request_url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/comments/43406728"},"html":{"href":"https://github.com/go-macaroon/js-macaroon/pull/7#discussion_r43406728"},"pull_request":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7","id":49160631,"html_url":"https://github.com/go-macaroon/js-macaroon/pull/7","diff_url":"https://github.com/go-macaroon/js-macaroon/pull/7.diff","patch_url":"https://github.com/go-macaroon/js-macaroon/pull/7.patch","issue_url":"https://api.github.com/repos/go-macaroon/js-macaroon/issues/7","number":7,"state":"open","locked":false,"title":"Small jshint.","user":{"login":"fabricematrat","id":1395842,"avatar_url":"https://avatars.githubusercontent.com/u/1395842?v=3","gravatar_id":"","url":"https://api.github.com/users/fabricematrat","html_url":"https://github.com/fabricematrat","followers_url":"https://api.github.com/users/fabricematrat/followers","following_url":"https://api.github.com/users/fabricematrat/following{/other_user}","gists_url":"https://api.github.com/users/fabricematrat/gists{/gist_id}","starred_url":"https://api.github.com/users/fabricematrat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabricematrat/subscriptions","organizations_url":"https://api.github.com/users/fabricematrat/orgs","repos_url":"https://api.github.com/users/fabricematrat/repos","events_url":"https://api.github.com/users/fabricematrat/events{/privacy}","received_events_url":"https://api.github.com/users/fabricematrat/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-29T16:02:43Z","updated_at":"2015-10-29T16:13:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f05ab3c57e54fa19e3f23b923bff7f8a9b4577d7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7/commits","review_comments_url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7/comments","review_comment_url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/go-macaroon/js-macaroon/issues/7/comments","statuses_url":"https://api.github.com/repos/go-macaroon/js-macaroon/statuses/2ccc492ed1a3f2da4d95b7689c5aa552ab5ad975","head":{"label":"fabricematrat:apply-juju-changes","ref":"apply-juju-changes","sha":"2ccc492ed1a3f2da4d95b7689c5aa552ab5ad975","user":{"login":"fabricematrat","id":1395842,"avatar_url":"https://avatars.githubusercontent.com/u/1395842?v=3","gravatar_id":"","url":"https://api.github.com/users/fabricematrat","html_url":"https://github.com/fabricematrat","followers_url":"https://api.github.com/users/fabricematrat/followers","following_url":"https://api.github.com/users/fabricematrat/following{/other_user}","gists_url":"https://api.github.com/users/fabricematrat/gists{/gist_id}","starred_url":"https://api.github.com/users/fabricematrat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabricematrat/subscriptions","organizations_url":"https://api.github.com/users/fabricematrat/orgs","repos_url":"https://api.github.com/users/fabricematrat/repos","events_url":"https://api.github.com/users/fabricematrat/events{/privacy}","received_events_url":"https://api.github.com/users/fabricematrat/received_events","type":"User","site_admin":false},"repo":{"id":44319087,"name":"js-macaroon","full_name":"fabricematrat/js-macaroon","owner":{"login":"fabricematrat","id":1395842,"avatar_url":"https://avatars.githubusercontent.com/u/1395842?v=3","gravatar_id":"","url":"https://api.github.com/users/fabricematrat","html_url":"https://github.com/fabricematrat","followers_url":"https://api.github.com/users/fabricematrat/followers","following_url":"https://api.github.com/users/fabricematrat/following{/other_user}","gists_url":"https://api.github.com/users/fabricematrat/gists{/gist_id}","starred_url":"https://api.github.com/users/fabricematrat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fabricematrat/subscriptions","organizations_url":"https://api.github.com/users/fabricematrat/orgs","repos_url":"https://api.github.com/users/fabricematrat/repos","events_url":"https://api.github.com/users/fabricematrat/events{/privacy}","received_events_url":"https://api.github.com/users/fabricematrat/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fabricematrat/js-macaroon","description":"Javascript implementation of macaroons","fork":true,"url":"https://api.github.com/repos/fabricematrat/js-macaroon","forks_url":"https://api.github.com/repos/fabricematrat/js-macaroon/forks","keys_url":"https://api.github.com/repos/fabricematrat/js-macaroon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fabricematrat/js-macaroon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fabricematrat/js-macaroon/teams","hooks_url":"https://api.github.com/repos/fabricematrat/js-macaroon/hooks","issue_events_url":"https://api.github.com/repos/fabricematrat/js-macaroon/issues/events{/number}","events_url":"https://api.github.com/repos/fabricematrat/js-macaroon/events","assignees_url":"https://api.github.com/repos/fabricematrat/js-macaroon/assignees{/user}","branches_url":"https://api.github.com/repos/fabricematrat/js-macaroon/branches{/branch}","tags_url":"https://api.github.com/repos/fabricematrat/js-macaroon/tags","blobs_url":"https://api.github.com/repos/fabricematrat/js-macaroon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fabricematrat/js-macaroon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fabricematrat/js-macaroon/git/refs{/sha}","trees_url":"https://api.github.com/repos/fabricematrat/js-macaroon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fabricematrat/js-macaroon/statuses/{sha}","languages_url":"https://api.github.com/repos/fabricematrat/js-macaroon/languages","stargazers_url":"https://api.github.com/repos/fabricematrat/js-macaroon/stargazers","contributors_url":"https://api.github.com/repos/fabricematrat/js-macaroon/contributors","subscribers_url":"https://api.github.com/repos/fabricematrat/js-macaroon/subscribers","subscription_url":"https://api.github.com/repos/fabricematrat/js-macaroon/subscription","commits_url":"https://api.github.com/repos/fabricematrat/js-macaroon/commits{/sha}","git_commits_url":"https://api.github.com/repos/fabricematrat/js-macaroon/git/commits{/sha}","comments_url":"https://api.github.com/repos/fabricematrat/js-macaroon/comments{/number}","issue_comment_url":"https://api.github.com/repos/fabricematrat/js-macaroon/issues/comments{/number}","contents_url":"https://api.github.com/repos/fabricematrat/js-macaroon/contents/{+path}","compare_url":"https://api.github.com/repos/fabricematrat/js-macaroon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fabricematrat/js-macaroon/merges","archive_url":"https://api.github.com/repos/fabricematrat/js-macaroon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fabricematrat/js-macaroon/downloads","issues_url":"https://api.github.com/repos/fabricematrat/js-macaroon/issues{/number}","pulls_url":"https://api.github.com/repos/fabricematrat/js-macaroon/pulls{/number}","milestones_url":"https://api.github.com/repos/fabricematrat/js-macaroon/milestones{/number}","notifications_url":"https://api.github.com/repos/fabricematrat/js-macaroon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fabricematrat/js-macaroon/labels{/name}","releases_url":"https://api.github.com/repos/fabricematrat/js-macaroon/releases{/id}","created_at":"2015-10-15T13:24:27Z","updated_at":"2015-10-15T13:24:27Z","pushed_at":"2015-10-29T16:01:43Z","git_url":"git://github.com/fabricematrat/js-macaroon.git","ssh_url":"git@github.com:fabricematrat/js-macaroon.git","clone_url":"https://github.com/fabricematrat/js-macaroon.git","svn_url":"https://github.com/fabricematrat/js-macaroon","homepage":null,"size":104,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"go-macaroon:master","ref":"master","sha":"5e85de84d25d74fed73eafb1ea85997cd60579a0","user":{"login":"go-macaroon","id":7963855,"avatar_url":"https://avatars.githubusercontent.com/u/7963855?v=3","gravatar_id":"","url":"https://api.github.com/users/go-macaroon","html_url":"https://github.com/go-macaroon","followers_url":"https://api.github.com/users/go-macaroon/followers","following_url":"https://api.github.com/users/go-macaroon/following{/other_user}","gists_url":"https://api.github.com/users/go-macaroon/gists{/gist_id}","starred_url":"https://api.github.com/users/go-macaroon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-macaroon/subscriptions","organizations_url":"https://api.github.com/users/go-macaroon/orgs","repos_url":"https://api.github.com/users/go-macaroon/repos","events_url":"https://api.github.com/users/go-macaroon/events{/privacy}","received_events_url":"https://api.github.com/users/go-macaroon/received_events","type":"Organization","site_admin":false},"repo":{"id":28780674,"name":"js-macaroon","full_name":"go-macaroon/js-macaroon","owner":{"login":"go-macaroon","id":7963855,"avatar_url":"https://avatars.githubusercontent.com/u/7963855?v=3","gravatar_id":"","url":"https://api.github.com/users/go-macaroon","html_url":"https://github.com/go-macaroon","followers_url":"https://api.github.com/users/go-macaroon/followers","following_url":"https://api.github.com/users/go-macaroon/following{/other_user}","gists_url":"https://api.github.com/users/go-macaroon/gists{/gist_id}","starred_url":"https://api.github.com/users/go-macaroon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/go-macaroon/subscriptions","organizations_url":"https://api.github.com/users/go-macaroon/orgs","repos_url":"https://api.github.com/users/go-macaroon/repos","events_url":"https://api.github.com/users/go-macaroon/events{/privacy}","received_events_url":"https://api.github.com/users/go-macaroon/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/go-macaroon/js-macaroon","description":"Javascript implementation of macaroons","fork":false,"url":"https://api.github.com/repos/go-macaroon/js-macaroon","forks_url":"https://api.github.com/repos/go-macaroon/js-macaroon/forks","keys_url":"https://api.github.com/repos/go-macaroon/js-macaroon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/go-macaroon/js-macaroon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/go-macaroon/js-macaroon/teams","hooks_url":"https://api.github.com/repos/go-macaroon/js-macaroon/hooks","issue_events_url":"https://api.github.com/repos/go-macaroon/js-macaroon/issues/events{/number}","events_url":"https://api.github.com/repos/go-macaroon/js-macaroon/events","assignees_url":"https://api.github.com/repos/go-macaroon/js-macaroon/assignees{/user}","branches_url":"https://api.github.com/repos/go-macaroon/js-macaroon/branches{/branch}","tags_url":"https://api.github.com/repos/go-macaroon/js-macaroon/tags","blobs_url":"https://api.github.com/repos/go-macaroon/js-macaroon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/go-macaroon/js-macaroon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/go-macaroon/js-macaroon/git/refs{/sha}","trees_url":"https://api.github.com/repos/go-macaroon/js-macaroon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/go-macaroon/js-macaroon/statuses/{sha}","languages_url":"https://api.github.com/repos/go-macaroon/js-macaroon/languages","stargazers_url":"https://api.github.com/repos/go-macaroon/js-macaroon/stargazers","contributors_url":"https://api.github.com/repos/go-macaroon/js-macaroon/contributors","subscribers_url":"https://api.github.com/repos/go-macaroon/js-macaroon/subscribers","subscription_url":"https://api.github.com/repos/go-macaroon/js-macaroon/subscription","commits_url":"https://api.github.com/repos/go-macaroon/js-macaroon/commits{/sha}","git_commits_url":"https://api.github.com/repos/go-macaroon/js-macaroon/git/commits{/sha}","comments_url":"https://api.github.com/repos/go-macaroon/js-macaroon/comments{/number}","issue_comment_url":"https://api.github.com/repos/go-macaroon/js-macaroon/issues/comments{/number}","contents_url":"https://api.github.com/repos/go-macaroon/js-macaroon/contents/{+path}","compare_url":"https://api.github.com/repos/go-macaroon/js-macaroon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/go-macaroon/js-macaroon/merges","archive_url":"https://api.github.com/repos/go-macaroon/js-macaroon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/go-macaroon/js-macaroon/downloads","issues_url":"https://api.github.com/repos/go-macaroon/js-macaroon/issues{/number}","pulls_url":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls{/number}","milestones_url":"https://api.github.com/repos/go-macaroon/js-macaroon/milestones{/number}","notifications_url":"https://api.github.com/repos/go-macaroon/js-macaroon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/go-macaroon/js-macaroon/labels{/name}","releases_url":"https://api.github.com/repos/go-macaroon/js-macaroon/releases{/id}","created_at":"2015-01-04T17:24:05Z","updated_at":"2015-03-14T23:01:22Z","pushed_at":"2015-10-29T16:02:45Z","git_url":"git://github.com/go-macaroon/js-macaroon.git","ssh_url":"git@github.com:go-macaroon/js-macaroon.git","clone_url":"https://github.com/go-macaroon/js-macaroon.git","svn_url":"https://github.com/go-macaroon/js-macaroon","homepage":null,"size":201,"stargazers_count":4,"watchers_count":4,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":1,"forks":6,"open_issues":1,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7"},"html":{"href":"https://github.com/go-macaroon/js-macaroon/pull/7"},"issue":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/issues/7"},"comments":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/go-macaroon/js-macaroon/statuses/2ccc492ed1a3f2da4d95b7689c5aa552ab5ad975"}}}}