{"action":"created","issue":{"url":"https://api.github.com/repos/lodash/lodash/issues/3850","repository_url":"https://api.github.com/repos/lodash/lodash","labels_url":"https://api.github.com/repos/lodash/lodash/issues/3850/labels{/name}","comments_url":"https://api.github.com/repos/lodash/lodash/issues/3850/comments","events_url":"https://api.github.com/repos/lodash/lodash/issues/3850/events","html_url":"https://github.com/lodash/lodash/issues/3850","id":336312536,"node_id":"MDU6SXNzdWUzMzYzMTI1MzY=","number":3850,"title":"documentation of `_.transform` doesn't match implimentation.","user":{"login":"graingert","id":413772,"node_id":"MDQ6VXNlcjQxMzc3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/413772?v=4","gravatar_id":"","url":"https://api.github.com/users/graingert","html_url":"https://github.com/graingert","followers_url":"https://api.github.com/users/graingert/followers","following_url":"https://api.github.com/users/graingert/following{/other_user}","gists_url":"https://api.github.com/users/graingert/gists{/gist_id}","starred_url":"https://api.github.com/users/graingert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graingert/subscriptions","organizations_url":"https://api.github.com/users/graingert/orgs","repos_url":"https://api.github.com/users/graingert/repos","events_url":"https://api.github.com/users/graingert/events{/privacy}","received_events_url":"https://api.github.com/users/graingert/received_events","type":"User","site_admin":false},"labels":[{"id":9649680,"node_id":"MDU6TGFiZWw5NjQ5Njgw","url":"https://api.github.com/repos/lodash/lodash/labels/documentation","name":"documentation","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-06-27T17:00:55Z","updated_at":"2018-06-27T17:15:06Z","closed_at":null,"author_association":"NONE","body":"Documentation claims to use string keyed properties:\r\n\r\n> An alternative to _.reduce; this method transforms object to a new accumulator object which is the result of running each of its own enumerable string keyed properties thru iteratee, with each invocation potentially mutating the accumulator object. If accumulator is not provided, a new object with the same [[Prototype]] will be used. The iteratee is invoked with four arguments: (accumulator, value, key, object). Iteratee functions may exit iteration early by explicitly returning false.\r\n\r\nHowever in the source it checks for Array, and switches to `arrayEach` https://github.com/lodash/lodash/blob/4.13.1/lodash.js#L13130\r\n\r\nHere's a demo of the difference in behaviour: \r\n\r\nhttps://runkit.com/graingert/transform-bad-docs\r\n\r\n```js\r\nconst assert = require('assert');\r\nconst _ = require('lodash');\r\n\r\nconst collection = [1, 2, 3];\r\n\r\ncollection.foo = 4;\r\n\r\nconst newCollection = [];\r\nfor (let x in collection) {\r\n  if (Object.prototype.hasOwnProperty.call(collection, x)) {\r\n    newCollection.push(collection[x]);\r\n  }\r\n}\r\nassert.deepEqual(newCollection, [1, 2, 3, 4]);\r\n\r\nconst newCollection2 = _.transform(collection, (acc, next) => { acc.push(next) }, []);\r\nassert.deepEqual(newCollection2, [1, 2, 3]);\r\n\r\nconsole.log('iterating own string keyed properties', newCollection)\r\nconsole.log('using transform', newCollection2);\r\n```\r\n\r\nPerhaps the documentation should be updated like:\r\n\r\n> An alternative to _.reduce; this method transforms object to a new accumulator object which if object is a Array-like is the result of running each element in object thu iteratee, else is the result of running each of its own enumerable string keyed properties thru iteratee, with each invocation potentially mutating the accumulator object. If accumulator is not provided, a new object with the same [[Prototype]] will be used. The iteratee is invoked with four arguments: (accumulator, value, key, object). Iteratee functions may exit iteration early by explicitly returning false.\r\n\r\nOr the check should be removed and `_.transform` should always use `string keyed properties`"},"comment":{"url":"https://api.github.com/repos/lodash/lodash/issues/comments/400761785","html_url":"https://github.com/lodash/lodash/issues/3850#issuecomment-400761785","issue_url":"https://api.github.com/repos/lodash/lodash/issues/3850","id":400761785,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDc2MTc4NQ==","user":{"login":"graingert","id":413772,"node_id":"MDQ6VXNlcjQxMzc3Mg==","avatar_url":"https://avatars3.githubusercontent.com/u/413772?v=4","gravatar_id":"","url":"https://api.github.com/users/graingert","html_url":"https://github.com/graingert","followers_url":"https://api.github.com/users/graingert/followers","following_url":"https://api.github.com/users/graingert/following{/other_user}","gists_url":"https://api.github.com/users/graingert/gists{/gist_id}","starred_url":"https://api.github.com/users/graingert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/graingert/subscriptions","organizations_url":"https://api.github.com/users/graingert/orgs","repos_url":"https://api.github.com/users/graingert/repos","events_url":"https://api.github.com/users/graingert/events{/privacy}","received_events_url":"https://api.github.com/users/graingert/received_events","type":"User","site_admin":false},"created_at":"2018-06-27T17:15:06Z","updated_at":"2018-06-27T17:15:06Z","author_association":"NONE","body":"@jdalton can you give me a hand with the wording of it"}}
{"actor":{"display_login":"graingert"}}