sindresorhus / camelcase-keys

Convert object keys to camel case
MIT License
689 stars 92 forks source link

Can `exclude` option support function parameter? #80

Open lessfish opened 2 years ago

lessfish commented 2 years ago

In my case

const obj = { '_name': true }
console.log(camelcaseKeys(obj)); // { name: true }

but I don't want to lose leading _ in _name, how can I achieve it?

Thanks

sindresorhus commented 2 years ago

It could, yes, but you can also solve this with a regex: {exclude: [/^_/]}.

lessfish commented 2 years ago

I just want to keep the leading _, for example, when the string is _name_obj, I just want to get _nameObj after conversion

with {exclude: [/^_/]}, it will stay _name_obj, is there some way to achieve it? Or it is not a normal demand?

sindresorhus commented 2 years ago

I think we could add a preserveLeadingUnderscore: true option. Must be added to camelcase first though.

wizardpisces commented 2 years ago

Any progress? Want to skip camelcase for BigNumber Object, it seems exclude support function would be more reasonable