Open andymerskin opened 1 year ago
This seems like an opinion rather than a correctness issue:
https://stackoverflow.com/questions/58009622/whats-the-correct-way-to-treat-numbers-in-snake-case
In which case I'm not especially inclined to pursue a breaking change.
Could this offered as a configurable option, especially since the consensus in that opinion favors what I'm suggesting here? It would also be beneficial for this library to at least offer comparable functionality to popular libraries like lodash
, etc. so that case conversion can remain consistent and predictable.
Example with option:
const object = {
foo01: "value",
};
snakecaseKeys(object, { separateNumbers: true });
// { foo_01: "value" }
Probably not, as maintaining variations on what snake case means becomes very complex. And bringing in multiple libraries to handle those is both complex and bloats the package.
I'll certainly accept a PR that makes the snake case function an option so you can pass your own.
Fair points — I love that idea better!
Due to the way the
snake-case
package handles numbers, keys ending with numbers aren't being properly snake_cased.Example keys:
Whereas
lodash
's snakeCase utility does properly separate numbers from alphabetical characters:This may mean this library's underlying case conversion library would need to be swapped, or updated, but unfortunately it hasn't been maintained in several years.