{"action":"created","comment":{"url":"https://api.github.com/repos/substack/node-resolve/pulls/comments/92718728","pull_request_review_id":13240108,"id":92718728,"diff_hunk":"@@ -46,7 +46,7 @@ module.exports = function resolve (x, opts, cb) {\n     else loadNodeModules(x, y, function (err, n, pkg) {\n         if (err) cb(err)\n         else if (n) cb(null, n, pkg)\n-        else if (core[x]) return cb(null, x);\n+        else if (core[x]) return cb(null, x, null);","path":"lib/async.js","position":5,"original_position":5,"commit_id":"9028537572fa59e4386622efe0c8cb3f14f4dbe0","original_commit_id":"9028537572fa59e4386622efe0c8cb3f14f4dbe0","user":{"login":"mpal9000","id":2001232,"avatar_url":"https://avatars.githubusercontent.com/u/2001232?v=3","gravatar_id":"","url":"https://api.github.com/users/mpal9000","html_url":"https://github.com/mpal9000","followers_url":"https://api.github.com/users/mpal9000/followers","following_url":"https://api.github.com/users/mpal9000/following{/other_user}","gists_url":"https://api.github.com/users/mpal9000/gists{/gist_id}","starred_url":"https://api.github.com/users/mpal9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpal9000/subscriptions","organizations_url":"https://api.github.com/users/mpal9000/orgs","repos_url":"https://api.github.com/users/mpal9000/repos","events_url":"https://api.github.com/users/mpal9000/events{/privacy}","received_events_url":"https://api.github.com/users/mpal9000/received_events","type":"User","site_admin":false},"body":"Hello, the problem is a rare case of libraries combination.\r\nWhen multiple values are returned from a thunkified function that is run inside \"co\", the result is an array. See https://github.com/tj/co/blob/master/index.js#L139\r\nMaybe it should always return an array, but it's about convenience vs. consistency.\r\nOn the other side \"resolve\", as a lower level lib, could handle problems like this, by always returning the same number of values.\r\n\r\nAlso your \"slice(0, 2)\" version inside the generator function, is not equivalent for the \"unpatched\" version. The first one does array destructuring, so it expects the sourced result to be an array and returns an array. The second one has the same behavior only for an array result, but for single value results it returns a string.\r\n```javascript\r\nconst [filePath, pkg] = yield resolve('path')\r\nreturn [filePath, pkg] //=> ['p', 'a']\r\n// vs.\r\nreturn (yield resolve('path')).slice(0, 2) //=> 'pa'\r\n```\r\nIn the \"patched\" version we get `[ 'path', null ]` from both.","created_at":"2016-12-15T22:55:34Z","updated_at":"2016-12-15T22:55:34Z","html_url":"https://github.com/substack/node-resolve/pull/56#discussion_r92718728","pull_request_url":"https://api.github.com/repos/substack/node-resolve/pulls/56","_links":{"self":{"href":"https://api.github.com/repos/substack/node-resolve/pulls/comments/92718728"},"html":{"href":"https://github.com/substack/node-resolve/pull/56#discussion_r92718728"},"pull_request":{"href":"https://api.github.com/repos/substack/node-resolve/pulls/56"}}},"pull_request":{"url":"https://api.github.com/repos/substack/node-resolve/pulls/56","id":22805374,"html_url":"https://github.com/substack/node-resolve/pull/56","diff_url":"https://github.com/substack/node-resolve/pull/56.diff","patch_url":"https://github.com/substack/node-resolve/pull/56.patch","issue_url":"https://api.github.com/repos/substack/node-resolve/issues/56","number":56,"state":"open","locked":false,"title":"Return null as pkg for core modules","user":{"login":"mpal9000","id":2001232,"avatar_url":"https://avatars.githubusercontent.com/u/2001232?v=3","gravatar_id":"","url":"https://api.github.com/users/mpal9000","html_url":"https://github.com/mpal9000","followers_url":"https://api.github.com/users/mpal9000/followers","following_url":"https://api.github.com/users/mpal9000/following{/other_user}","gists_url":"https://api.github.com/users/mpal9000/gists{/gist_id}","starred_url":"https://api.github.com/users/mpal9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpal9000/subscriptions","organizations_url":"https://api.github.com/users/mpal9000/orgs","repos_url":"https://api.github.com/users/mpal9000/repos","events_url":"https://api.github.com/users/mpal9000/events{/privacy}","received_events_url":"https://api.github.com/users/mpal9000/received_events","type":"User","site_admin":false},"body":"Hello, thanks for everything you share! This pull request is about a small issue that I have when combining \"resolve\" with \"thunkify\" and generators.\n\n``` javascript\nvar resolve = thunkify(require('resolve'));\n\nfunction* gen() {\n  // I want to write\n  let [filePath, pkg] = yield resolve(modulePath, opts);\n\n  // But when the `modulePath` is a core module's name (eg. \"path\"), I have to write\n  let res = yield resolve(modulePath, opts);\n  let filePath = Array.isArray(res) ? res[0] : res;\n  let pkg = Array.isArray(res) ? res[1] : null;\n}\n```\n","created_at":"2014-10-15T18:44:38Z","updated_at":"2016-12-15T22:55:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b9045e88b81b6b1d264d5b204e12238791118246","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/substack/node-resolve/pulls/56/commits","review_comments_url":"https://api.github.com/repos/substack/node-resolve/pulls/56/comments","review_comment_url":"https://api.github.com/repos/substack/node-resolve/pulls/comments{/number}","comments_url":"https://api.github.com/repos/substack/node-resolve/issues/56/comments","statuses_url":"https://api.github.com/repos/substack/node-resolve/statuses/9028537572fa59e4386622efe0c8cb3f14f4dbe0","head":{"label":"mpal9000:mods","ref":"mods","sha":"9028537572fa59e4386622efe0c8cb3f14f4dbe0","user":{"login":"mpal9000","id":2001232,"avatar_url":"https://avatars.githubusercontent.com/u/2001232?v=3","gravatar_id":"","url":"https://api.github.com/users/mpal9000","html_url":"https://github.com/mpal9000","followers_url":"https://api.github.com/users/mpal9000/followers","following_url":"https://api.github.com/users/mpal9000/following{/other_user}","gists_url":"https://api.github.com/users/mpal9000/gists{/gist_id}","starred_url":"https://api.github.com/users/mpal9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpal9000/subscriptions","organizations_url":"https://api.github.com/users/mpal9000/orgs","repos_url":"https://api.github.com/users/mpal9000/repos","events_url":"https://api.github.com/users/mpal9000/events{/privacy}","received_events_url":"https://api.github.com/users/mpal9000/received_events","type":"User","site_admin":false},"repo":{"id":25267326,"name":"node-resolve","full_name":"mpal9000/node-resolve","owner":{"login":"mpal9000","id":2001232,"avatar_url":"https://avatars.githubusercontent.com/u/2001232?v=3","gravatar_id":"","url":"https://api.github.com/users/mpal9000","html_url":"https://github.com/mpal9000","followers_url":"https://api.github.com/users/mpal9000/followers","following_url":"https://api.github.com/users/mpal9000/following{/other_user}","gists_url":"https://api.github.com/users/mpal9000/gists{/gist_id}","starred_url":"https://api.github.com/users/mpal9000/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpal9000/subscriptions","organizations_url":"https://api.github.com/users/mpal9000/orgs","repos_url":"https://api.github.com/users/mpal9000/repos","events_url":"https://api.github.com/users/mpal9000/events{/privacy}","received_events_url":"https://api.github.com/users/mpal9000/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mpal9000/node-resolve","description":"Implements the node.js require.resolve() algorithm","fork":true,"url":"https://api.github.com/repos/mpal9000/node-resolve","forks_url":"https://api.github.com/repos/mpal9000/node-resolve/forks","keys_url":"https://api.github.com/repos/mpal9000/node-resolve/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mpal9000/node-resolve/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mpal9000/node-resolve/teams","hooks_url":"https://api.github.com/repos/mpal9000/node-resolve/hooks","issue_events_url":"https://api.github.com/repos/mpal9000/node-resolve/issues/events{/number}","events_url":"https://api.github.com/repos/mpal9000/node-resolve/events","assignees_url":"https://api.github.com/repos/mpal9000/node-resolve/assignees{/user}","branches_url":"https://api.github.com/repos/mpal9000/node-resolve/branches{/branch}","tags_url":"https://api.github.com/repos/mpal9000/node-resolve/tags","blobs_url":"https://api.github.com/repos/mpal9000/node-resolve/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mpal9000/node-resolve/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mpal9000/node-resolve/git/refs{/sha}","trees_url":"https://api.github.com/repos/mpal9000/node-resolve/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mpal9000/node-resolve/statuses/{sha}","languages_url":"https://api.github.com/repos/mpal9000/node-resolve/languages","stargazers_url":"https://api.github.com/repos/mpal9000/node-resolve/stargazers","contributors_url":"https://api.github.com/repos/mpal9000/node-resolve/contributors","subscribers_url":"https://api.github.com/repos/mpal9000/node-resolve/subscribers","subscription_url":"https://api.github.com/repos/mpal9000/node-resolve/subscription","commits_url":"https://api.github.com/repos/mpal9000/node-resolve/commits{/sha}","git_commits_url":"https://api.github.com/repos/mpal9000/node-resolve/git/commits{/sha}","comments_url":"https://api.github.com/repos/mpal9000/node-resolve/comments{/number}","issue_comment_url":"https://api.github.com/repos/mpal9000/node-resolve/issues/comments{/number}","contents_url":"https://api.github.com/repos/mpal9000/node-resolve/contents/{+path}","compare_url":"https://api.github.com/repos/mpal9000/node-resolve/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mpal9000/node-resolve/merges","archive_url":"https://api.github.com/repos/mpal9000/node-resolve/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mpal9000/node-resolve/downloads","issues_url":"https://api.github.com/repos/mpal9000/node-resolve/issues{/number}","pulls_url":"https://api.github.com/repos/mpal9000/node-resolve/pulls{/number}","milestones_url":"https://api.github.com/repos/mpal9000/node-resolve/milestones{/number}","notifications_url":"https://api.github.com/repos/mpal9000/node-resolve/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mpal9000/node-resolve/labels{/name}","releases_url":"https://api.github.com/repos/mpal9000/node-resolve/releases{/id}","deployments_url":"https://api.github.com/repos/mpal9000/node-resolve/deployments","created_at":"2014-10-15T18:16:53Z","updated_at":"2014-10-15T10:50:06Z","pushed_at":"2014-10-15T18:41:29Z","git_url":"git://github.com/mpal9000/node-resolve.git","ssh_url":"git@github.com:mpal9000/node-resolve.git","clone_url":"https://github.com/mpal9000/node-resolve.git","svn_url":"https://github.com/mpal9000/node-resolve","homepage":"","size":171,"stargazers_count":0,"watchers_count":0,"language":null,"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":"substack:master","ref":"master","sha":"6d8494e8d4c3ede3fce620388cc3631632a17f8a","user":{"login":"substack","id":12631,"avatar_url":"https://avatars.githubusercontent.com/u/12631?v=3","gravatar_id":"","url":"https://api.github.com/users/substack","html_url":"https://github.com/substack","followers_url":"https://api.github.com/users/substack/followers","following_url":"https://api.github.com/users/substack/following{/other_user}","gists_url":"https://api.github.com/users/substack/gists{/gist_id}","starred_url":"https://api.github.com/users/substack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/substack/subscriptions","organizations_url":"https://api.github.com/users/substack/orgs","repos_url":"https://api.github.com/users/substack/repos","events_url":"https://api.github.com/users/substack/events{/privacy}","received_events_url":"https://api.github.com/users/substack/received_events","type":"User","site_admin":false},"repo":{"id":1915099,"name":"node-resolve","full_name":"substack/node-resolve","owner":{"login":"substack","id":12631,"avatar_url":"https://avatars.githubusercontent.com/u/12631?v=3","gravatar_id":"","url":"https://api.github.com/users/substack","html_url":"https://github.com/substack","followers_url":"https://api.github.com/users/substack/followers","following_url":"https://api.github.com/users/substack/following{/other_user}","gists_url":"https://api.github.com/users/substack/gists{/gist_id}","starred_url":"https://api.github.com/users/substack/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/substack/subscriptions","organizations_url":"https://api.github.com/users/substack/orgs","repos_url":"https://api.github.com/users/substack/repos","events_url":"https://api.github.com/users/substack/events{/privacy}","received_events_url":"https://api.github.com/users/substack/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/substack/node-resolve","description":"Implements the node.js require.resolve() algorithm","fork":false,"url":"https://api.github.com/repos/substack/node-resolve","forks_url":"https://api.github.com/repos/substack/node-resolve/forks","keys_url":"https://api.github.com/repos/substack/node-resolve/keys{/key_id}","collaborators_url":"https://api.github.com/repos/substack/node-resolve/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/substack/node-resolve/teams","hooks_url":"https://api.github.com/repos/substack/node-resolve/hooks","issue_events_url":"https://api.github.com/repos/substack/node-resolve/issues/events{/number}","events_url":"https://api.github.com/repos/substack/node-resolve/events","assignees_url":"https://api.github.com/repos/substack/node-resolve/assignees{/user}","branches_url":"https://api.github.com/repos/substack/node-resolve/branches{/branch}","tags_url":"https://api.github.com/repos/substack/node-resolve/tags","blobs_url":"https://api.github.com/repos/substack/node-resolve/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/substack/node-resolve/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/substack/node-resolve/git/refs{/sha}","trees_url":"https://api.github.com/repos/substack/node-resolve/git/trees{/sha}","statuses_url":"https://api.github.com/repos/substack/node-resolve/statuses/{sha}","languages_url":"https://api.github.com/repos/substack/node-resolve/languages","stargazers_url":"https://api.github.com/repos/substack/node-resolve/stargazers","contributors_url":"https://api.github.com/repos/substack/node-resolve/contributors","subscribers_url":"https://api.github.com/repos/substack/node-resolve/subscribers","subscription_url":"https://api.github.com/repos/substack/node-resolve/subscription","commits_url":"https://api.github.com/repos/substack/node-resolve/commits{/sha}","git_commits_url":"https://api.github.com/repos/substack/node-resolve/git/commits{/sha}","comments_url":"https://api.github.com/repos/substack/node-resolve/comments{/number}","issue_comment_url":"https://api.github.com/repos/substack/node-resolve/issues/comments{/number}","contents_url":"https://api.github.com/repos/substack/node-resolve/contents/{+path}","compare_url":"https://api.github.com/repos/substack/node-resolve/compare/{base}...{head}","merges_url":"https://api.github.com/repos/substack/node-resolve/merges","archive_url":"https://api.github.com/repos/substack/node-resolve/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/substack/node-resolve/downloads","issues_url":"https://api.github.com/repos/substack/node-resolve/issues{/number}","pulls_url":"https://api.github.com/repos/substack/node-resolve/pulls{/number}","milestones_url":"https://api.github.com/repos/substack/node-resolve/milestones{/number}","notifications_url":"https://api.github.com/repos/substack/node-resolve/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/substack/node-resolve/labels{/name}","releases_url":"https://api.github.com/repos/substack/node-resolve/releases{/id}","deployments_url":"https://api.github.com/repos/substack/node-resolve/deployments","created_at":"2011-06-18T09:37:24Z","updated_at":"2016-12-15T17:08:17Z","pushed_at":"2016-12-14T08:54:11Z","git_url":"git://github.com/substack/node-resolve.git","ssh_url":"git@github.com:substack/node-resolve.git","clone_url":"https://github.com/substack/node-resolve.git","svn_url":"https://github.com/substack/node-resolve","homepage":"","size":118,"stargazers_count":308,"watchers_count":308,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":87,"mirror_url":null,"open_issues_count":34,"forks":87,"open_issues":34,"watchers":308,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/substack/node-resolve/pulls/56"},"html":{"href":"https://github.com/substack/node-resolve/pull/56"},"issue":{"href":"https://api.github.com/repos/substack/node-resolve/issues/56"},"comments":{"href":"https://api.github.com/repos/substack/node-resolve/issues/56/comments"},"review_comments":{"href":"https://api.github.com/repos/substack/node-resolve/pulls/56/comments"},"review_comment":{"href":"https://api.github.com/repos/substack/node-resolve/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/substack/node-resolve/pulls/56/commits"},"statuses":{"href":"https://api.github.com/repos/substack/node-resolve/statuses/9028537572fa59e4386622efe0c8cb3f14f4dbe0"}}}}
{"actor":{"display_login":"mpal9000"}}