Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar
by sindresorhusJavaScript
Last 12 weeks · 1 commit
4 of 6 standards met
In this PR Based on this issue #77 If understood correctly, what's needed is for strings' characters to change to lower case or upper case only if they are not after a number. For example: Chars after numbers do not change index.js Created a helper function called applyCasingExceptAfterNumber, which is responsible to apply case functions to all chars except the ones after a number. It takes as parameters the string, and the case function. test.js Updated 6 tests in order for the new desired effect to be the correct one package.json Update the xo dependency version in order for tests to run due to a bug presented in previous xojs/xo versions
I noticed that is not idempotent, which I think is a bug. i.e. if is meant to return a camel-cased version of the input, then camel-casing it _again_ should not result in a diff because it's already been camel-cased. I've added a failing property-based test for this, but haven't figured out what the implementation bug is exactly. Feel free to merge as-is, but I may update this PR with an actual bug fix if I have time. An example of a case that fails is :
Repository: sindresorhus/camelcase. Description: Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar Stars: 698, Forks: 100. Primary language: JavaScript. Languages: JavaScript (96.8%), TypeScript (3.2%). License: MIT. Latest release: v9.0.0 (9mo ago). Open PRs: 0, open issues: 0. Last activity: 1mo ago. Community health: 85%. Top contributors: sindresorhus, SamVerschueren, DanielSeehausen, Qix-, BendingBender, kevva, qw-in, rocktimsaikia, sverweij, mesaugat and others.