{"action":"created","comment":{"url":"https://api.github.com/repos/wikimedia/html-metadata/pulls/comments/29556736","id":29556736,"diff_hunk":"@@ -5,99 +5,47 @@\n \n 'use strict';\n \n-var async = require('async'),\n-\tcheerio = require('cheerio'),\n-\trequest = require('request'),\n-\tmicrodata = require('microdata-node');\n+var BBPromise = require('bluebird');\n+var cheerio = require('cheerio');\n+var preq = require('preq');\n+var microdata = require('microdata-node');\n \n // Default exported function\n-exports = module.exports = function(urlOrOpts, callback){\n-\trequest(urlOrOpts, function(error, response, html){\n-\t\tvar chtml = cheerio.load(html);\n-\t\texports.parseAll(chtml, function(err, results){\n-\t\t\tcallback(err, results);\n-\t\t});\n+exports = module.exports = function(urlOrOpts) {\n+\treturn preq.get(urlOrOpts\n+\t).then(function(callRes) {\n+\t\treturn BBPromise.resolve(exports.parseAll(cheerio.load(callRes.body)));\n \t});\n };\n \n /**\n- * Callback on Object containing all fields merged into\n- * one object. The parameters key to a list which may contain\n- * multiple values if multiples are found (for instance, if\n- * multiple metadata types exist and both contain a parameter\n- * called 'title')\n- *\n- * @param  {Object}   chtml     html Cheerio object to parse\n- * @param  {Function} callback callback(error, mergedObject)\n- */\n-exports.parseAllMerged = function(chtml, callback){\n-\tvar fcn, results, merged,\n-\t\tallMetadata = {},\n-\t\tmetadataFunctions = exports.metadataFunctions;\n-\n-\tasync.eachSeries(Object.keys(metadataFunctions), function (key, cb){\n-\t\tfcn = metadataFunctions[key];\n-\t\tfcn(chtml, function(results){\n-\t\t\tif (results){\n-\t\t\t\t// Merge results into larger object\n-\t\t\t\tfor (var key in results){\n-\t\t\t\t\tmerged = allMetadata[key];\n-\t\t\t\t\tvar value = results[key];\n-\n-\t\t\t\t\tif (!merged){\n-\t\t\t\t\t\tmerged = [];\n-\t\t\t\t\t}\n-\n-\t\t\t\t\tif (value instanceof Array) {\n-\t\t\t\t\t\tmerged = merged.concat(value);\n-\t\t\t\t\t} else {\n-\t\t\t\t\t\tmerged.push(value);\n-\t\t\t\t\t}\n-\n-\t\t\t\t\tallMetadata[key] = merged;\n-\t\t\t\t}\n-\t\t\t}\n-\t\t});\n-\t\tcb();\n-\t}, function(err) {\n-\t\tcallback(err, allMetadata);\n-\t});\n-};\n-\n-/**\n- * Callback on Object containing all available datatypes, keyed\n+ * Returns Object containing all available datatypes, keyed\n  * using the same keys as in metadataFunctions.\n  *\n- * Currently only openGraph data as this is the only one implemented\n- *\n- * @param  {Object}   chtml     html Cheerio object to parse\n- * @param  {Function} callback callback(error, allMetadata)\n+ * @param  {Object}   chtml html Cheerio object to parse\n+ * @return {Object}         contains metadata\n  */\n-exports.parseAll = function(chtml, callback){\n-\tvar fcn,\n-\t\tallMetadata = {},\n-\t\tmetadataFunctions = exports.metadataFunctions;\n+exports.parseAll = function(chtml){\n+\tvar fcn;\n+\tvar meta;\n+\tvar allMetadata = {};\n+\tvar metadataFunctions = exports.metadataFunctions;\n \n-\tasync.forEach(Object.keys(metadataFunctions), function (key, cb){\n+\tObject.keys(metadataFunctions).forEach(function(key) {","path":"index.js","position":null,"original_position":94,"commit_id":"45ff9553b24ffc002ad58627a962d976833218f0","original_commit_id":"80f6154f0ac22d2709e301154c9a3ca645957957","user":{"login":"mvolz","id":351040,"avatar_url":"https://avatars.githubusercontent.com/u/351040?v=3","gravatar_id":"","url":"https://api.github.com/users/mvolz","html_url":"https://github.com/mvolz","followers_url":"https://api.github.com/users/mvolz/followers","following_url":"https://api.github.com/users/mvolz/following{/other_user}","gists_url":"https://api.github.com/users/mvolz/gists{/gist_id}","starred_url":"https://api.github.com/users/mvolz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvolz/subscriptions","organizations_url":"https://api.github.com/users/mvolz/orgs","repos_url":"https://api.github.com/users/mvolz/repos","events_url":"https://api.github.com/users/mvolz/events{/privacy}","received_events_url":"https://api.github.com/users/mvolz/received_events","type":"User","site_admin":false},"body":"Working on it in new WIP commit. (Just letting you know because in IRC you mentioned that you might do this :))","created_at":"2015-05-03T14:56:58Z","updated_at":"2015-05-03T14:56:58Z","html_url":"https://github.com/wikimedia/html-metadata/pull/15#discussion_r29556736","pull_request_url":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15","_links":{"self":{"href":"https://api.github.com/repos/wikimedia/html-metadata/pulls/comments/29556736"},"html":{"href":"https://github.com/wikimedia/html-metadata/pull/15#discussion_r29556736"},"pull_request":{"href":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15"}}},"pull_request":{"url":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15","id":33973067,"html_url":"https://github.com/wikimedia/html-metadata/pull/15","diff_url":"https://github.com/wikimedia/html-metadata/pull/15.diff","patch_url":"https://github.com/wikimedia/html-metadata/pull/15.patch","issue_url":"https://api.github.com/repos/wikimedia/html-metadata/issues/15","number":15,"state":"open","locked":false,"title":"[BREAKING] Promisify entire package","user":{"login":"mvolz","id":351040,"avatar_url":"https://avatars.githubusercontent.com/u/351040?v=3","gravatar_id":"","url":"https://api.github.com/users/mvolz","html_url":"https://github.com/mvolz","followers_url":"https://api.github.com/users/mvolz/followers","following_url":"https://api.github.com/users/mvolz/following{/other_user}","gists_url":"https://api.github.com/users/mvolz/gists{/gist_id}","starred_url":"https://api.github.com/users/mvolz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvolz/subscriptions","organizations_url":"https://api.github.com/users/mvolz/orgs","repos_url":"https://api.github.com/users/mvolz/repos","events_url":"https://api.github.com/users/mvolz/events{/privacy}","received_events_url":"https://api.github.com/users/mvolz/received_events","type":"User","site_admin":false},"body":"* Default export function returns a promise\r\n* Most methods now syncronous instead of using callbacks\r\n* Update version indicating non-backwards compatible\r\nchanes\r\n* Move test in index.js to test/index.js\r\n* Move test_files to test/static\r\n\r\nBug: T96363","created_at":"2015-04-23T16:32:42Z","updated_at":"2015-05-03T14:56:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"44b1704e8cbd824265811cf6a509f04c1c889ff4","assignee":{"login":"d00rman","id":10210173,"avatar_url":"https://avatars.githubusercontent.com/u/10210173?v=3","gravatar_id":"","url":"https://api.github.com/users/d00rman","html_url":"https://github.com/d00rman","followers_url":"https://api.github.com/users/d00rman/followers","following_url":"https://api.github.com/users/d00rman/following{/other_user}","gists_url":"https://api.github.com/users/d00rman/gists{/gist_id}","starred_url":"https://api.github.com/users/d00rman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/d00rman/subscriptions","organizations_url":"https://api.github.com/users/d00rman/orgs","repos_url":"https://api.github.com/users/d00rman/repos","events_url":"https://api.github.com/users/d00rman/events{/privacy}","received_events_url":"https://api.github.com/users/d00rman/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15/commits","review_comments_url":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15/comments","review_comment_url":"https://api.github.com/repos/wikimedia/html-metadata/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wikimedia/html-metadata/issues/15/comments","statuses_url":"https://api.github.com/repos/wikimedia/html-metadata/statuses/45ff9553b24ffc002ad58627a962d976833218f0","head":{"label":"wikimedia:promisify","ref":"promisify","sha":"45ff9553b24ffc002ad58627a962d976833218f0","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":28137225,"name":"html-metadata","full_name":"wikimedia/html-metadata","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/html-metadata","description":"","fork":false,"url":"https://api.github.com/repos/wikimedia/html-metadata","forks_url":"https://api.github.com/repos/wikimedia/html-metadata/forks","keys_url":"https://api.github.com/repos/wikimedia/html-metadata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/html-metadata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/html-metadata/teams","hooks_url":"https://api.github.com/repos/wikimedia/html-metadata/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/html-metadata/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/html-metadata/events","assignees_url":"https://api.github.com/repos/wikimedia/html-metadata/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/html-metadata/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/html-metadata/tags","blobs_url":"https://api.github.com/repos/wikimedia/html-metadata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/html-metadata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/html-metadata/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/html-metadata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/html-metadata/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/html-metadata/languages","stargazers_url":"https://api.github.com/repos/wikimedia/html-metadata/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/html-metadata/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/html-metadata/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/html-metadata/subscription","commits_url":"https://api.github.com/repos/wikimedia/html-metadata/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/html-metadata/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/html-metadata/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/html-metadata/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/html-metadata/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/html-metadata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/html-metadata/merges","archive_url":"https://api.github.com/repos/wikimedia/html-metadata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/html-metadata/downloads","issues_url":"https://api.github.com/repos/wikimedia/html-metadata/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/html-metadata/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/html-metadata/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/html-metadata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/html-metadata/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/html-metadata/releases{/id}","created_at":"2014-12-17T12:54:28Z","updated_at":"2015-03-22T12:56:55Z","pushed_at":"2015-05-03T14:52:09Z","git_url":"git://github.com/wikimedia/html-metadata.git","ssh_url":"git@github.com:wikimedia/html-metadata.git","clone_url":"https://github.com/wikimedia/html-metadata.git","svn_url":"https://github.com/wikimedia/html-metadata","homepage":null,"size":499,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":3,"default_branch":"master"}},"base":{"label":"wikimedia:master","ref":"master","sha":"467b62f42207d3111e629208954893c71de6ac39","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":28137225,"name":"html-metadata","full_name":"wikimedia/html-metadata","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/html-metadata","description":"","fork":false,"url":"https://api.github.com/repos/wikimedia/html-metadata","forks_url":"https://api.github.com/repos/wikimedia/html-metadata/forks","keys_url":"https://api.github.com/repos/wikimedia/html-metadata/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/html-metadata/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/html-metadata/teams","hooks_url":"https://api.github.com/repos/wikimedia/html-metadata/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/html-metadata/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/html-metadata/events","assignees_url":"https://api.github.com/repos/wikimedia/html-metadata/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/html-metadata/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/html-metadata/tags","blobs_url":"https://api.github.com/repos/wikimedia/html-metadata/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/html-metadata/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/html-metadata/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/html-metadata/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/html-metadata/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/html-metadata/languages","stargazers_url":"https://api.github.com/repos/wikimedia/html-metadata/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/html-metadata/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/html-metadata/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/html-metadata/subscription","commits_url":"https://api.github.com/repos/wikimedia/html-metadata/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/html-metadata/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/html-metadata/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/html-metadata/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/html-metadata/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/html-metadata/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/html-metadata/merges","archive_url":"https://api.github.com/repos/wikimedia/html-metadata/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/html-metadata/downloads","issues_url":"https://api.github.com/repos/wikimedia/html-metadata/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/html-metadata/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/html-metadata/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/html-metadata/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/html-metadata/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/html-metadata/releases{/id}","created_at":"2014-12-17T12:54:28Z","updated_at":"2015-03-22T12:56:55Z","pushed_at":"2015-05-03T14:52:09Z","git_url":"git://github.com/wikimedia/html-metadata.git","ssh_url":"git@github.com:wikimedia/html-metadata.git","clone_url":"https://github.com/wikimedia/html-metadata.git","svn_url":"https://github.com/wikimedia/html-metadata","homepage":null,"size":499,"stargazers_count":3,"watchers_count":3,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":1,"forks":4,"open_issues":1,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15"},"html":{"href":"https://github.com/wikimedia/html-metadata/pull/15"},"issue":{"href":"https://api.github.com/repos/wikimedia/html-metadata/issues/15"},"comments":{"href":"https://api.github.com/repos/wikimedia/html-metadata/issues/15/comments"},"review_comments":{"href":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15/comments"},"review_comment":{"href":"https://api.github.com/repos/wikimedia/html-metadata/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wikimedia/html-metadata/pulls/15/commits"},"statuses":{"href":"https://api.github.com/repos/wikimedia/html-metadata/statuses/45ff9553b24ffc002ad58627a962d976833218f0"}}}}