sindresorhus / camelcase-keys

Convert object keys to camel case
MIT License
691 stars 95 forks source link

Options {deep: true} seem run incorrect #32

Closed ngocthoaia1 closed 5 years ago

ngocthoaia1 commented 5 years ago

Issuehunt badges

screenshot from 2019-02-25 13-23-10

camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true});
expect
//=> {fooBar: true, nested: {unicornRainbow: true}}
actual
//=> {fooBar: true, nested: {unicorn_rainbow: true}

IssueHunt Summary ### Backers (Total: $0.00) #### [Become a backer now!](https://issuehunt.io/r/sindresorhus/camelcase-keys/issues/32) #### [Or submit a pull request to get the deposits!](https://issuehunt.io/r/sindresorhus/camelcase-keys/issues/32) ### Tips - Checkout the [Issuehunt explorer](https://issuehunt.io/r/sindresorhus/camelcase-keys/) to discover more funded issues. - Need some help from other developers? [Add your repositories](https://issuehunt.io/r/new) on IssueHunt to raise funds. --- IssueHunt has been backed by the following sponsors. [Become a sponsor](https://issuehunt.io/membership/members)
abhn commented 5 years ago

Same issue here. What is weird in my case is that this was working fine a few days ago, but suddenly stopped when I tried it today.

IssueHuntBot commented 5 years ago

@issuehunt has funded $40.00 to this issue.


abhn commented 5 years ago

While I'm not submitting a PR to this, if anyone lands on this problem here's the a little script that you can add to your utils https://gist.github.com/abhn/cdfbdce6bf8a1e7be3750fd6607e6096

Code copied from https://matthiashager.com/converting-snake-case-to-camel-case-object-keys-with-javascript

Not as efficient as the library, but for smaller json files, shouldn't be that huge of a problem.

cinderblock commented 5 years ago

@ngocthoaia1 I'm not able to replicate this bug, at least with the latest version on Node.js. Where/how are you running this?

stroncium commented 5 years ago

@abhn Can you point to some reproduction steps? What was nodejs version/browser at least?

sasikanth513 commented 5 years ago

@abhn @ngocthoaia1

Yeah, I Cannot reproduce it either.

I tried with all the following node versions

  v6.2.2
  v7.10.0
  v8.9.0
  v8.9.4
  v8.11.3
  v9.5.0

it worked fine with all these versions, would be great to know steps to reproduce this issue.

abhn commented 5 years ago

Apologies for not getting back.

My node version is 8.9.1 and my camelcase-keys version is 2.1.0.

I'll try to install this project in another test setup and try to reproduce the issue there. But like I mentioned in my post, it did work fine for me for sometime and then faced the issue mentioned by OP so not sure.

I'll get back. I'm wondering if it has anything to do with the data supplied to the function.

sasikanth513 commented 5 years ago

@abhn sure, let us know what data object you are sending, if it breaks.

TiagoDanin commented 5 years ago

deep option was introduced in v4.0.0 (https://github.com/sindresorhus/camelcase-keys/commit/94195701442b3ab257d17596a689780656a172ec).

Aerlin commented 5 years ago

I too was having this issue with deep not working on nested objects. Since I knew it was working in a previous project, I downgraded to camelcase-keys@5.2.0 and it worked. I then tried v6.0.0 then c6.0.1 and they worked too.

Now I couldn't reproduce the issue. It didn't make any sense. I looked through all my dependencies and discovered node-sass was installing meow which was then installing camelcase-keys@2.1.0 for some reason (same version @abhn mentioned). I started a new project with just node-sass installed and sure enough the nested object issue came back.

So for me anyway it turned out another package had installed a older version of camelcase-keys instead of the latest version. Perhaps Op was experiencing a similar issue.

romanlex commented 5 years ago

Can confirm this trouble with camelcase-keys@6.0.1 and dependency from meow package (camelcase-keys@2.1.0)

ngocthoaia1 commented 5 years ago

@all So sorry for late reply, I miss the notifications. @romanlex I checked again and see "camelcase-keys" package don't have any problem. The problem seem I use too old version of "camelcase-keys" I use meow package too and it require

"requires": {
        "camelcase-keys": "^2.0.0",

I think can close this issue right now. Thank you a lots for you help!

issuehunt-oss[bot] commented 4 years ago

@sindresorhus has cancelled @issuehunt's funding for this issue.(Cancelled amount: $40.00) See it on IssueHunt