{"action":"created","comment":{"url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/comments/62562420","id":62562420,"diff_hunk":"@@ -102,5 +86,116 @@ var poke = function poke(d, i, pool, callback) {\n   return false;\n };\n \n+// Return the nth protein in the pool\n+var nth = function nth(pool, index, callback) {\n+  throw new Error('nth not implemented');\n+\n+  // this would be simple, except that p-nth spews the protein\n+  // rather than providing it as YAML, and peek does not\n+  // provide an nth option\n+  var child = spawn_process('p-nth ' + pool + ' ' + index);\n+  if (!child) return null;\n+\n+  child.stdout.setEncoding('utf8');\n+  var buffer = '';\n+  child.stdout.on('data', function(data) {\n+    buffer += data;\n+  });\n+  child.stdout.on('end', function() {\n+    process_protein(buffer, callback);\n+  });\n+  return child;\n+};\n+\n+// Return the newest protein in the pool\n+var newest = function newest(pool, callback) {\n+  var child = spawn_process('peek -1 ' + pool);\n+  if (!child) return null;\n+\n+  child.stdout.setEncoding('utf8');\n+  var buffer = ''\n+  child.stdout.on('data', function(data) {\n+    buffer += data;\n+  });\n+  child.stdout.on('end', function() {\n+    process_protein(buffer, callback);\n+  });\n+  return child;\n+};\n+\n+// Return the oldest protein in the pool\n+var oldest = function oldest(pool, callback) {\n+  var child = spawn_process('peek --rewind --limit 1 ' + pool);\n+  if (!child) return null;\n+\n+  child.stdout.setEncoding('utf8');\n+  var buffer = ''\n+  child.stdout.on('data', function(data) {\n+    buffer += data;\n+  });\n+  child.stdout.on('end', function() {\n+    process_protein(buffer, callback);\n+  });\n+  return child;\n+};\n+\n+// Return the newest index in the pool\n+var newest_idx = function newest_idx(pool, callback) {\n+  var child = spawn_process('p-newest-idx ' + pool);\n+  if (!child) return null;\n+\n+  child.stdout.setEncoding('utf8');\n+  child.stdout.on('data', function(data) {\n+    try {\n+      callback(parseInt(data));","path":"index.js","position":90,"original_position":90,"commit_id":"34939cdaa31239ad33b8a6252c38d9ec4745001e","original_commit_id":"34939cdaa31239ad33b8a6252c38d9ec4745001e","user":{"login":"ebeneliason","id":687448,"avatar_url":"https://avatars.githubusercontent.com/u/687448?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeneliason","html_url":"https://github.com/ebeneliason","followers_url":"https://api.github.com/users/ebeneliason/followers","following_url":"https://api.github.com/users/ebeneliason/following{/other_user}","gists_url":"https://api.github.com/users/ebeneliason/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeneliason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeneliason/subscriptions","organizations_url":"https://api.github.com/users/ebeneliason/orgs","repos_url":"https://api.github.com/users/ebeneliason/repos","events_url":"https://api.github.com/users/ebeneliason/events{/privacy}","received_events_url":"https://api.github.com/users/ebeneliason/received_events","type":"User","site_admin":false},"body":"Size…as in, is there any worry that I'm not accounting for the possibility that the on data handler will be called more than once? I considered that, but given that the output is always an integer and a single line, it didn't seem necessary.","created_at":"2016-05-09T19:59:28Z","updated_at":"2016-05-09T19:59:28Z","html_url":"https://github.com/Oblong/plasma-js-bridge/pull/7#discussion_r62562420","pull_request_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/comments/62562420"},"html":{"href":"https://github.com/Oblong/plasma-js-bridge/pull/7#discussion_r62562420"},"pull_request":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7","id":69227765,"html_url":"https://github.com/Oblong/plasma-js-bridge/pull/7","diff_url":"https://github.com/Oblong/plasma-js-bridge/pull/7.diff","patch_url":"https://github.com/Oblong/plasma-js-bridge/pull/7.patch","issue_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues/7","number":7,"state":"open","locked":false,"title":"Add oldest, newest, oldestIndex, and newestIndex support","user":{"login":"ebeneliason","id":687448,"avatar_url":"https://avatars.githubusercontent.com/u/687448?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeneliason","html_url":"https://github.com/ebeneliason","followers_url":"https://api.github.com/users/ebeneliason/followers","following_url":"https://api.github.com/users/ebeneliason/following{/other_user}","gists_url":"https://api.github.com/users/ebeneliason/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeneliason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeneliason/subscriptions","organizations_url":"https://api.github.com/users/ebeneliason/orgs","repos_url":"https://api.github.com/users/ebeneliason/repos","events_url":"https://api.github.com/users/ebeneliason/events{/privacy}","received_events_url":"https://api.github.com/users/ebeneliason/received_events","type":"User","site_admin":false},"body":"This is notably lacking nth, which is partially implemented but\r\nthrows an unimplemented error since p-nth doesn't return YAML\r\noutput and peek doesn't provide a simple nth option.\r\n\r\nThis comes with corresponding tests, though it should be noted\r\nthat the tests are not robust due to the asynchronous nature of\r\nthe functions being tested. Converting this to a promise API\r\nwould be a cleaner solution for reliable tests.","created_at":"2016-05-07T00:49:59Z","updated_at":"2016-05-09T19:59:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8fdaafb89bcbaa11f86ca60e404024b743f71fd5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7/commits","review_comments_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7/comments","review_comment_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues/7/comments","statuses_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/statuses/34939cdaa31239ad33b8a6252c38d9ec4745001e","head":{"label":"ebeneliason:oldest-newest","ref":"oldest-newest","sha":"34939cdaa31239ad33b8a6252c38d9ec4745001e","user":{"login":"ebeneliason","id":687448,"avatar_url":"https://avatars.githubusercontent.com/u/687448?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeneliason","html_url":"https://github.com/ebeneliason","followers_url":"https://api.github.com/users/ebeneliason/followers","following_url":"https://api.github.com/users/ebeneliason/following{/other_user}","gists_url":"https://api.github.com/users/ebeneliason/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeneliason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeneliason/subscriptions","organizations_url":"https://api.github.com/users/ebeneliason/orgs","repos_url":"https://api.github.com/users/ebeneliason/repos","events_url":"https://api.github.com/users/ebeneliason/events{/privacy}","received_events_url":"https://api.github.com/users/ebeneliason/received_events","type":"User","site_admin":false},"repo":{"id":58242391,"name":"plasma-js-bridge","full_name":"ebeneliason/plasma-js-bridge","owner":{"login":"ebeneliason","id":687448,"avatar_url":"https://avatars.githubusercontent.com/u/687448?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeneliason","html_url":"https://github.com/ebeneliason","followers_url":"https://api.github.com/users/ebeneliason/followers","following_url":"https://api.github.com/users/ebeneliason/following{/other_user}","gists_url":"https://api.github.com/users/ebeneliason/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeneliason/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeneliason/subscriptions","organizations_url":"https://api.github.com/users/ebeneliason/orgs","repos_url":"https://api.github.com/users/ebeneliason/repos","events_url":"https://api.github.com/users/ebeneliason/events{/privacy}","received_events_url":"https://api.github.com/users/ebeneliason/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ebeneliason/plasma-js-bridge","description":"Uses YAML to bridge between node.js and Oblong plasma peek/poke","fork":true,"url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge","forks_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/forks","keys_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/teams","hooks_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/hooks","issue_events_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/issues/events{/number}","events_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/events","assignees_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/assignees{/user}","branches_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/branches{/branch}","tags_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/tags","blobs_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/git/refs{/sha}","trees_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/statuses/{sha}","languages_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/languages","stargazers_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/stargazers","contributors_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/contributors","subscribers_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/subscribers","subscription_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/subscription","commits_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/commits{/sha}","git_commits_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/git/commits{/sha}","comments_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/comments{/number}","issue_comment_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/issues/comments{/number}","contents_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/contents/{+path}","compare_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/merges","archive_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/downloads","issues_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/issues{/number}","pulls_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/pulls{/number}","milestones_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/milestones{/number}","notifications_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/labels{/name}","releases_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/releases{/id}","deployments_url":"https://api.github.com/repos/ebeneliason/plasma-js-bridge/deployments","created_at":"2016-05-07T00:44:30Z","updated_at":"2016-05-07T00:44:31Z","pushed_at":"2016-05-07T00:51:56Z","git_url":"git://github.com/ebeneliason/plasma-js-bridge.git","ssh_url":"git@github.com:ebeneliason/plasma-js-bridge.git","clone_url":"https://github.com/ebeneliason/plasma-js-bridge.git","svn_url":"https://github.com/ebeneliason/plasma-js-bridge","homepage":null,"size":12,"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":"Oblong:master","ref":"master","sha":"1b24f36be1a0fafac094930a8f93b55b05f33493","user":{"login":"Oblong","id":974627,"avatar_url":"https://avatars.githubusercontent.com/u/974627?v=3","gravatar_id":"","url":"https://api.github.com/users/Oblong","html_url":"https://github.com/Oblong","followers_url":"https://api.github.com/users/Oblong/followers","following_url":"https://api.github.com/users/Oblong/following{/other_user}","gists_url":"https://api.github.com/users/Oblong/gists{/gist_id}","starred_url":"https://api.github.com/users/Oblong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Oblong/subscriptions","organizations_url":"https://api.github.com/users/Oblong/orgs","repos_url":"https://api.github.com/users/Oblong/repos","events_url":"https://api.github.com/users/Oblong/events{/privacy}","received_events_url":"https://api.github.com/users/Oblong/received_events","type":"Organization","site_admin":false},"repo":{"id":37946288,"name":"plasma-js-bridge","full_name":"Oblong/plasma-js-bridge","owner":{"login":"Oblong","id":974627,"avatar_url":"https://avatars.githubusercontent.com/u/974627?v=3","gravatar_id":"","url":"https://api.github.com/users/Oblong","html_url":"https://github.com/Oblong","followers_url":"https://api.github.com/users/Oblong/followers","following_url":"https://api.github.com/users/Oblong/following{/other_user}","gists_url":"https://api.github.com/users/Oblong/gists{/gist_id}","starred_url":"https://api.github.com/users/Oblong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Oblong/subscriptions","organizations_url":"https://api.github.com/users/Oblong/orgs","repos_url":"https://api.github.com/users/Oblong/repos","events_url":"https://api.github.com/users/Oblong/events{/privacy}","received_events_url":"https://api.github.com/users/Oblong/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Oblong/plasma-js-bridge","description":"Uses YAML to bridge between node.js and Oblong plasma peek/poke","fork":false,"url":"https://api.github.com/repos/Oblong/plasma-js-bridge","forks_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/forks","keys_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/teams","hooks_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/hooks","issue_events_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues/events{/number}","events_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/events","assignees_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/assignees{/user}","branches_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/branches{/branch}","tags_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/tags","blobs_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/git/refs{/sha}","trees_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/statuses/{sha}","languages_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/languages","stargazers_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/stargazers","contributors_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/contributors","subscribers_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/subscribers","subscription_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/subscription","commits_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/commits{/sha}","git_commits_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/git/commits{/sha}","comments_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/comments{/number}","issue_comment_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues/comments{/number}","contents_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/contents/{+path}","compare_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/merges","archive_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/downloads","issues_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues{/number}","pulls_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls{/number}","milestones_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/milestones{/number}","notifications_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/labels{/name}","releases_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/releases{/id}","deployments_url":"https://api.github.com/repos/Oblong/plasma-js-bridge/deployments","created_at":"2015-06-23T21:33:33Z","updated_at":"2015-06-23T21:33:53Z","pushed_at":"2016-05-07T00:51:57Z","git_url":"git://github.com/Oblong/plasma-js-bridge.git","ssh_url":"git@github.com:Oblong/plasma-js-bridge.git","clone_url":"https://github.com/Oblong/plasma-js-bridge.git","svn_url":"https://github.com/Oblong/plasma-js-bridge","homepage":null,"size":190,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":3,"forks":2,"open_issues":3,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7"},"html":{"href":"https://github.com/Oblong/plasma-js-bridge/pull/7"},"issue":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues/7"},"comments":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/Oblong/plasma-js-bridge/statuses/34939cdaa31239ad33b8a6252c38d9ec4745001e"}}}}