{"action":"created","issue":{"url":"https://api.github.com/repos/KyleAMathews/deepmerge/issues/114","repository_url":"https://api.github.com/repos/KyleAMathews/deepmerge","labels_url":"https://api.github.com/repos/KyleAMathews/deepmerge/issues/114/labels{/name}","comments_url":"https://api.github.com/repos/KyleAMathews/deepmerge/issues/114/comments","events_url":"https://api.github.com/repos/KyleAMathews/deepmerge/issues/114/events","html_url":"https://github.com/KyleAMathews/deepmerge/issues/114","id":336479247,"node_id":"MDU6SXNzdWUzMzY0NzkyNDc=","number":114,"title":"Make a check for string first, overwrite strings.","user":{"login":"mesqueeb","id":3253920,"node_id":"MDQ6VXNlcjMyNTM5MjA=","avatar_url":"https://avatars3.githubusercontent.com/u/3253920?v=4","gravatar_id":"","url":"https://api.github.com/users/mesqueeb","html_url":"https://github.com/mesqueeb","followers_url":"https://api.github.com/users/mesqueeb/followers","following_url":"https://api.github.com/users/mesqueeb/following{/other_user}","gists_url":"https://api.github.com/users/mesqueeb/gists{/gist_id}","starred_url":"https://api.github.com/users/mesqueeb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mesqueeb/subscriptions","organizations_url":"https://api.github.com/users/mesqueeb/orgs","repos_url":"https://api.github.com/users/mesqueeb/repos","events_url":"https://api.github.com/users/mesqueeb/events{/privacy}","received_events_url":"https://api.github.com/users/mesqueeb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-28T05:38:29Z","updated_at":"2018-06-28T22:23:29Z","closed_at":null,"author_association":"NONE","body":"I have an object with lots of props, some of them are objects, some string.\r\nI am looping over each key to see if it already exists on another object.\r\nif it does, i'm merging the value of those props.\r\n**however, this is sometimes not an object but a string!**\r\n\r\nWith merge() if I try `merge('ab', 'ba')` I end up with an object: `{0: 'b', 1: 'a'}`.\r\n\r\nMaybe deepmerge can first check if it's really an object, and if it's strings just return the last string?\r\n\r\nmy snippet:\r\n```\r\nreturn Object.keys(doc).forEach(key => {\r\n          // Merge if exists\r\n          const newVal = (state[key])\r\n            ? merge(state[key], doc[key], {arrayMerge: overwriteMerge})\r\n            : doc[key]\r\n          this._vm.$set(state, key, newVal)\r\n        })\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/KyleAMathews/deepmerge/issues/comments/401191240","html_url":"https://github.com/KyleAMathews/deepmerge/issues/114#issuecomment-401191240","issue_url":"https://api.github.com/repos/KyleAMathews/deepmerge/issues/114","id":401191240,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMTE5MTI0MA==","user":{"login":"macdja38","id":5033246,"node_id":"MDQ6VXNlcjUwMzMyNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/5033246?v=4","gravatar_id":"","url":"https://api.github.com/users/macdja38","html_url":"https://github.com/macdja38","followers_url":"https://api.github.com/users/macdja38/followers","following_url":"https://api.github.com/users/macdja38/following{/other_user}","gists_url":"https://api.github.com/users/macdja38/gists{/gist_id}","starred_url":"https://api.github.com/users/macdja38/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macdja38/subscriptions","organizations_url":"https://api.github.com/users/macdja38/orgs","repos_url":"https://api.github.com/users/macdja38/repos","events_url":"https://api.github.com/users/macdja38/events{/privacy}","received_events_url":"https://api.github.com/users/macdja38/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T22:23:29Z","updated_at":"2018-06-28T22:23:29Z","author_association":"COLLABORATOR","body":"I'm not sure this warrants a special case, potentially it might make more sense to either wrap deep merge in your code or simply check if it's a string before merging. If anything deep merge should probably throw an error, it was never designed to work on strings, and doesn't really have a valid way of *merging* strings.\r\n\r\nLet me know your thoughts on why this should be built into the library and in what cases this would be the expected behaviour. "}}
{"actor":{"display_login":"macdja38"}}