{"action":"created","comment":{"url":"https://api.github.com/repos/chaijs/pathval/pulls/comments/70161073","id":70161073,"diff_hunk":"@@ -0,0 +1,211 @@\n+'use strict';\n+\n+var assert = require('simple-assert');\n+var pathval = require('..');\n+describe('hasProperty', function () {\n+  it('should handle array index', function () {\n+    var arr = [ 1, 2, 'cheeseburger' ];\n+    assert(pathval.hasProperty(1, arr) === true);\n+    assert(pathval.hasProperty(3, arr) === false);\n+  });\n+\n+  it('should handle literal types', function () {\n+    var exampleString = 'string literal';\n+    assert(pathval.hasProperty('length', exampleString) === true);\n+    assert(pathval.hasProperty(3, exampleString) === true);\n+    assert(pathval.hasProperty(14, exampleString) === false);\n+    assert(pathval.hasProperty('foo', 1) === false);\n+  });\n+\n+  it('should handle undefined', function () {\n+    var exampleObj = {\n+      foo: 'bar',\n+    };\n+    assert(pathval.hasProperty('foo', exampleObj) === true);\n+    assert(pathval.hasProperty('baz', exampleObj) === false);\n+    assert(pathval.hasProperty(0, exampleObj) === false);\n+  });\n+\n+  it('should handle undefined', function () {\n+    assert(pathval.hasProperty('foo', undefined) === false);\n+  });\n+\n+  it('should handle null', function () {\n+    assert(pathval.hasProperty('foo', null) === false);\n+  });\n+});\n+\n+describe('getPathInfo', function () {\n+  var obj = {\n+    id: '10702S300W',\n+    primes: [ 2, 3, 5, 7, 11 ],\n+    dimensions: {\n+      units: 'mm',\n+      lengths: [ [ 1.2, 3.5 ], [ 2.2, 1.5 ], [ 5, 7 ] ],\n+    },\n+    'dimensions.lengths': {\n+      '[2]': [ 1.2, 3.5 ],\n+    },\n+  };\n+  var gpi = pathval.getPathInfo;\n+  it('should handle simple property', function () {\n+    var info = gpi('dimensions.units', obj);\n+    assert(info.parent === obj.dimensions);\n+    assert(info.value === obj.dimensions.units);\n+    assert(info.name === 'units');\n+    assert(info.exists === true);\n+  });\n+\n+  it('should handle non-existent property', function () {\n+    var info = gpi('dimensions.size', obj);\n+    assert(info.parent === obj.dimensions);\n+    assert(info.value === undefined);\n+    assert(info.name === 'size');\n+    assert(info.exists === false);\n+  });\n+\n+  it('should handle array index', function () {\n+    var info = gpi('primes[2]', obj);\n+    assert(info.parent === obj.primes);\n+    assert(info.value === obj.primes[2]);\n+    assert(info.name === 2);\n+    assert(info.exists === true);\n+  });\n+\n+  it('should handle dimensional array', function () {\n+    var info = gpi('dimensions.lengths[2][1]', obj);\n+    assert(info.parent === obj.dimensions.lengths[2]);\n+    assert(info.value === obj.dimensions.lengths[2][1]);\n+    assert(info.name === 1);\n+    assert(info.exists === true);\n+  });\n+\n+  it('should handle out of bounds array index', function () {\n+    var info = gpi('dimensions.lengths[3]', obj);\n+    assert(info.parent === obj.dimensions.lengths);\n+    assert(info.value === undefined);\n+    assert(info.name === 3);\n+    assert(info.exists === false);\n+  });\n+\n+  it('should handle out of bounds dimensional array index', function () {\n+    var info = gpi('dimensions.lengths[2][5]', obj);\n+    assert(info.parent === obj.dimensions.lengths[2]);\n+    assert(info.value === undefined);\n+    assert(info.name === 5);\n+    assert(info.exists === false);\n+  });\n+\n+  it('should handle backslash-escaping for .[]', function () {\n+    var info = gpi('dimensions\\\\.lengths.\\\\[2\\\\][1]', obj);\n+    assert(info.parent === obj['dimensions.lengths']['[2]']);\n+    assert(info.value === obj['dimensions.lengths']['[2]'][1]);\n+    assert(info.name === 1);\n+    assert(info.exists === true);\n+  });\n+});\n+\n+describe('getPathValue', function () {\n+  it('returns the correct value', function () {\n+    var object = {\n+      hello: 'universe',\n+      universe: {\n+        hello: 'world',\n+      },\n+      world: [ 'hello', 'universe' ],\n+      complex: [\n+        { hello: 'universe' },\n+        { universe: 'world' },\n+        [ { hello: 'world' } ],\n+      ],\n+    };\n+\n+    var arr = [ [ true ] ];\n+    assert(pathval.getPathValue('hello', object) === 'universe');\n+    assert(pathval.getPathValue('universe.hello', object) === 'world');\n+    assert(pathval.getPathValue('world[1]', object) === 'universe');\n+    assert(pathval.getPathValue('complex[1].universe', object) === 'world');\n+    assert(pathval.getPathValue('complex[2][0].hello', object) === 'world');\n+    assert(pathval.getPathValue('[0][0]', arr) === true);\n+  });\n+\n+  it('handles undefined objects and properties', function () {\n+    var object = {};\n+    assert(pathval.getPathValue('this.should.work', undefined) === null);\n+    assert(pathval.getPathValue('this.should.work', object) === null);\n+    assert(pathval.getPathValue('length', 'word') === 4);\n+  });\n+});\n+\n+describe('setPathValue', function () {\n+  it('allows value to be set in simple object', function () {\n+    var obj = {};\n+    pathval.setPathValue('hello', obj, 'universe');\n+    assert(obj.hello === 'universe');\n+  });\n+\n+  it('allows nested object value to be set', function () {\n+    var obj = {};\n+    pathval.setPathValue('hello.universe', obj, 'properties');\n+    assert(obj.hello.universe === 'properties');\n+  });\n+\n+  it('allows nested array value to be set', function () {\n+    var obj = {};\n+    pathval.setPathValue('hello.universe[1].properties', obj, 'galaxy');\n+    assert(obj.hello.universe[1].properties === 'galaxy');\n+  });\n+\n+  it('allows value to be REset in simple object', function () {","path":"test/index.js","position":159,"original_position":159,"commit_id":"61eeb926b335f5efc4a993628c7f3a1df8356ece","original_commit_id":"61eeb926b335f5efc4a993628c7f3a1df8356ece","user":{"login":"meeber","id":17260989,"avatar_url":"https://avatars.githubusercontent.com/u/17260989?v=3","gravatar_id":"","url":"https://api.github.com/users/meeber","html_url":"https://github.com/meeber","followers_url":"https://api.github.com/users/meeber/followers","following_url":"https://api.github.com/users/meeber/following{/other_user}","gists_url":"https://api.github.com/users/meeber/gists{/gist_id}","starred_url":"https://api.github.com/users/meeber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/meeber/subscriptions","organizations_url":"https://api.github.com/users/meeber/orgs","repos_url":"https://api.github.com/users/meeber/repos","events_url":"https://api.github.com/users/meeber/events{/privacy}","received_events_url":"https://api.github.com/users/meeber/received_events","type":"User","site_admin":false},"body":"Is there significance of capitalization in `REset` or is that just a search/replace side-effect?","created_at":"2016-07-09T02:43:52Z","updated_at":"2016-07-09T02:43:52Z","html_url":"https://github.com/chaijs/pathval/pull/11#discussion_r70161073","pull_request_url":"https://api.github.com/repos/chaijs/pathval/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/chaijs/pathval/pulls/comments/70161073"},"html":{"href":"https://github.com/chaijs/pathval/pull/11#discussion_r70161073"},"pull_request":{"href":"https://api.github.com/repos/chaijs/pathval/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/chaijs/pathval/pulls/11","id":76074153,"html_url":"https://github.com/chaijs/pathval/pull/11","diff_url":"https://github.com/chaijs/pathval/pull/11.diff","patch_url":"https://github.com/chaijs/pathval/pull/11.patch","issue_url":"https://api.github.com/repos/chaijs/pathval/issues/11","number":11,"state":"open","locked":false,"title":"add Chai's pathval features to this separate module","user":{"login":"lucasfcosta","id":6868147,"avatar_url":"https://avatars.githubusercontent.com/u/6868147?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasfcosta","html_url":"https://github.com/lucasfcosta","followers_url":"https://api.github.com/users/lucasfcosta/followers","following_url":"https://api.github.com/users/lucasfcosta/following{/other_user}","gists_url":"https://api.github.com/users/lucasfcosta/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasfcosta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasfcosta/subscriptions","organizations_url":"https://api.github.com/users/lucasfcosta/orgs","repos_url":"https://api.github.com/users/lucasfcosta/repos","events_url":"https://api.github.com/users/lucasfcosta/events{/privacy}","received_events_url":"https://api.github.com/users/lucasfcosta/received_events","type":"User","site_admin":false},"body":"This PR holds the progress I've made on moving Chai's `pathval` features to this separate module.\r\nI have done some changes to the code brought here in order to have 100% coverage and follow the linting rules defined.\r\n\r\nThis is almost done, but I'd still like to refactor some parts of the code, such as turning the `internalSetPathValue` function into a recursive function and maybe renaming some variables for them to make sense.\r\n\r\nIf you have any other refactoring suggestions please let me know.\r\nI'll remove the `[WIP]` tag and do another post here when I finish this one.\r\n\r\n**Important Detail:**\r\n[Currently the build is failing for Node `0.8` because `type-detect` (which is a dependency of `pathval`) needs a Node version above `0.1.0`.](https://travis-ci.org/chaijs/pathval/jobs/141903679#L230) What are we going to do about it? According to [the `type-detect` package.json](https://github.com/chaijs/type-detect/blob/master/package.json#L83) it should be compatible with any Node.js version as soon as the version on the repo gets released.\r\n\r\nThanks for your attention 😄 \r\n\r\n---------------------------------------------------------------------\r\nEDIT: This one is done. Please read the comment below.","created_at":"2016-07-02T20:43:50Z","updated_at":"2016-07-09T02:43:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dbad8c61c4783bf791b2fb597a706290d3c0e667","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/chaijs/pathval/pulls/11/commits","review_comments_url":"https://api.github.com/repos/chaijs/pathval/pulls/11/comments","review_comment_url":"https://api.github.com/repos/chaijs/pathval/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chaijs/pathval/issues/11/comments","statuses_url":"https://api.github.com/repos/chaijs/pathval/statuses/61eeb926b335f5efc4a993628c7f3a1df8356ece","head":{"label":"lucasfcosta:chai-pathval-into-separate-module","ref":"chai-pathval-into-separate-module","sha":"61eeb926b335f5efc4a993628c7f3a1df8356ece","user":{"login":"lucasfcosta","id":6868147,"avatar_url":"https://avatars.githubusercontent.com/u/6868147?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasfcosta","html_url":"https://github.com/lucasfcosta","followers_url":"https://api.github.com/users/lucasfcosta/followers","following_url":"https://api.github.com/users/lucasfcosta/following{/other_user}","gists_url":"https://api.github.com/users/lucasfcosta/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasfcosta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasfcosta/subscriptions","organizations_url":"https://api.github.com/users/lucasfcosta/orgs","repos_url":"https://api.github.com/users/lucasfcosta/repos","events_url":"https://api.github.com/users/lucasfcosta/events{/privacy}","received_events_url":"https://api.github.com/users/lucasfcosta/received_events","type":"User","site_admin":false},"repo":{"id":62076552,"name":"pathval","full_name":"lucasfcosta/pathval","owner":{"login":"lucasfcosta","id":6868147,"avatar_url":"https://avatars.githubusercontent.com/u/6868147?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasfcosta","html_url":"https://github.com/lucasfcosta","followers_url":"https://api.github.com/users/lucasfcosta/followers","following_url":"https://api.github.com/users/lucasfcosta/following{/other_user}","gists_url":"https://api.github.com/users/lucasfcosta/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasfcosta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasfcosta/subscriptions","organizations_url":"https://api.github.com/users/lucasfcosta/orgs","repos_url":"https://api.github.com/users/lucasfcosta/repos","events_url":"https://api.github.com/users/lucasfcosta/events{/privacy}","received_events_url":"https://api.github.com/users/lucasfcosta/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lucasfcosta/pathval","description":"Object value retrieval given a string path","fork":true,"url":"https://api.github.com/repos/lucasfcosta/pathval","forks_url":"https://api.github.com/repos/lucasfcosta/pathval/forks","keys_url":"https://api.github.com/repos/lucasfcosta/pathval/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucasfcosta/pathval/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucasfcosta/pathval/teams","hooks_url":"https://api.github.com/repos/lucasfcosta/pathval/hooks","issue_events_url":"https://api.github.com/repos/lucasfcosta/pathval/issues/events{/number}","events_url":"https://api.github.com/repos/lucasfcosta/pathval/events","assignees_url":"https://api.github.com/repos/lucasfcosta/pathval/assignees{/user}","branches_url":"https://api.github.com/repos/lucasfcosta/pathval/branches{/branch}","tags_url":"https://api.github.com/repos/lucasfcosta/pathval/tags","blobs_url":"https://api.github.com/repos/lucasfcosta/pathval/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucasfcosta/pathval/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucasfcosta/pathval/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucasfcosta/pathval/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucasfcosta/pathval/statuses/{sha}","languages_url":"https://api.github.com/repos/lucasfcosta/pathval/languages","stargazers_url":"https://api.github.com/repos/lucasfcosta/pathval/stargazers","contributors_url":"https://api.github.com/repos/lucasfcosta/pathval/contributors","subscribers_url":"https://api.github.com/repos/lucasfcosta/pathval/subscribers","subscription_url":"https://api.github.com/repos/lucasfcosta/pathval/subscription","commits_url":"https://api.github.com/repos/lucasfcosta/pathval/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucasfcosta/pathval/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucasfcosta/pathval/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucasfcosta/pathval/issues/comments{/number}","contents_url":"https://api.github.com/repos/lucasfcosta/pathval/contents/{+path}","compare_url":"https://api.github.com/repos/lucasfcosta/pathval/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucasfcosta/pathval/merges","archive_url":"https://api.github.com/repos/lucasfcosta/pathval/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucasfcosta/pathval/downloads","issues_url":"https://api.github.com/repos/lucasfcosta/pathval/issues{/number}","pulls_url":"https://api.github.com/repos/lucasfcosta/pathval/pulls{/number}","milestones_url":"https://api.github.com/repos/lucasfcosta/pathval/milestones{/number}","notifications_url":"https://api.github.com/repos/lucasfcosta/pathval/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucasfcosta/pathval/labels{/name}","releases_url":"https://api.github.com/repos/lucasfcosta/pathval/releases{/id}","deployments_url":"https://api.github.com/repos/lucasfcosta/pathval/deployments","created_at":"2016-06-27T17:59:53Z","updated_at":"2016-06-27T17:59:54Z","pushed_at":"2016-07-09T02:16:22Z","git_url":"git://github.com/lucasfcosta/pathval.git","ssh_url":"git@github.com:lucasfcosta/pathval.git","clone_url":"https://github.com/lucasfcosta/pathval.git","svn_url":"https://github.com/lucasfcosta/pathval","homepage":null,"size":28,"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":"chaijs:master","ref":"master","sha":"1959b75c57c856afae675e9da23201750f0981c1","user":{"login":"chaijs","id":1515293,"avatar_url":"https://avatars.githubusercontent.com/u/1515293?v=3","gravatar_id":"","url":"https://api.github.com/users/chaijs","html_url":"https://github.com/chaijs","followers_url":"https://api.github.com/users/chaijs/followers","following_url":"https://api.github.com/users/chaijs/following{/other_user}","gists_url":"https://api.github.com/users/chaijs/gists{/gist_id}","starred_url":"https://api.github.com/users/chaijs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaijs/subscriptions","organizations_url":"https://api.github.com/users/chaijs/orgs","repos_url":"https://api.github.com/users/chaijs/repos","events_url":"https://api.github.com/users/chaijs/events{/privacy}","received_events_url":"https://api.github.com/users/chaijs/received_events","type":"Organization","site_admin":false},"repo":{"id":14665922,"name":"pathval","full_name":"chaijs/pathval","owner":{"login":"chaijs","id":1515293,"avatar_url":"https://avatars.githubusercontent.com/u/1515293?v=3","gravatar_id":"","url":"https://api.github.com/users/chaijs","html_url":"https://github.com/chaijs","followers_url":"https://api.github.com/users/chaijs/followers","following_url":"https://api.github.com/users/chaijs/following{/other_user}","gists_url":"https://api.github.com/users/chaijs/gists{/gist_id}","starred_url":"https://api.github.com/users/chaijs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chaijs/subscriptions","organizations_url":"https://api.github.com/users/chaijs/orgs","repos_url":"https://api.github.com/users/chaijs/repos","events_url":"https://api.github.com/users/chaijs/events{/privacy}","received_events_url":"https://api.github.com/users/chaijs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chaijs/pathval","description":"Object value retrieval given a string path","fork":false,"url":"https://api.github.com/repos/chaijs/pathval","forks_url":"https://api.github.com/repos/chaijs/pathval/forks","keys_url":"https://api.github.com/repos/chaijs/pathval/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chaijs/pathval/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chaijs/pathval/teams","hooks_url":"https://api.github.com/repos/chaijs/pathval/hooks","issue_events_url":"https://api.github.com/repos/chaijs/pathval/issues/events{/number}","events_url":"https://api.github.com/repos/chaijs/pathval/events","assignees_url":"https://api.github.com/repos/chaijs/pathval/assignees{/user}","branches_url":"https://api.github.com/repos/chaijs/pathval/branches{/branch}","tags_url":"https://api.github.com/repos/chaijs/pathval/tags","blobs_url":"https://api.github.com/repos/chaijs/pathval/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chaijs/pathval/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chaijs/pathval/git/refs{/sha}","trees_url":"https://api.github.com/repos/chaijs/pathval/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chaijs/pathval/statuses/{sha}","languages_url":"https://api.github.com/repos/chaijs/pathval/languages","stargazers_url":"https://api.github.com/repos/chaijs/pathval/stargazers","contributors_url":"https://api.github.com/repos/chaijs/pathval/contributors","subscribers_url":"https://api.github.com/repos/chaijs/pathval/subscribers","subscription_url":"https://api.github.com/repos/chaijs/pathval/subscription","commits_url":"https://api.github.com/repos/chaijs/pathval/commits{/sha}","git_commits_url":"https://api.github.com/repos/chaijs/pathval/git/commits{/sha}","comments_url":"https://api.github.com/repos/chaijs/pathval/comments{/number}","issue_comment_url":"https://api.github.com/repos/chaijs/pathval/issues/comments{/number}","contents_url":"https://api.github.com/repos/chaijs/pathval/contents/{+path}","compare_url":"https://api.github.com/repos/chaijs/pathval/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chaijs/pathval/merges","archive_url":"https://api.github.com/repos/chaijs/pathval/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chaijs/pathval/downloads","issues_url":"https://api.github.com/repos/chaijs/pathval/issues{/number}","pulls_url":"https://api.github.com/repos/chaijs/pathval/pulls{/number}","milestones_url":"https://api.github.com/repos/chaijs/pathval/milestones{/number}","notifications_url":"https://api.github.com/repos/chaijs/pathval/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chaijs/pathval/labels{/name}","releases_url":"https://api.github.com/repos/chaijs/pathval/releases{/id}","deployments_url":"https://api.github.com/repos/chaijs/pathval/deployments","created_at":"2013-11-24T17:51:21Z","updated_at":"2016-06-27T17:59:50Z","pushed_at":"2016-07-09T02:16:22Z","git_url":"git://github.com/chaijs/pathval.git","ssh_url":"git@github.com:chaijs/pathval.git","clone_url":"https://github.com/chaijs/pathval.git","svn_url":"https://github.com/chaijs/pathval","homepage":null,"size":17,"stargazers_count":30,"watchers_count":30,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":7,"forks":4,"open_issues":7,"watchers":30,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chaijs/pathval/pulls/11"},"html":{"href":"https://github.com/chaijs/pathval/pull/11"},"issue":{"href":"https://api.github.com/repos/chaijs/pathval/issues/11"},"comments":{"href":"https://api.github.com/repos/chaijs/pathval/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/chaijs/pathval/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/chaijs/pathval/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chaijs/pathval/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/chaijs/pathval/statuses/61eeb926b335f5efc4a993628c7f3a1df8356ece"}}}}
{"actor":{"display_login":"meeber"}}