Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add optional argument for toDash and camelCase #214

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dpolac
Copy link

@dpolac dpolac commented May 1, 2016

If specified, it's used instead of dash. Does not break BC.

If specified, it's used instead of dash. Does not break BC.
@jgonggrijp jgonggrijp added before modules This needs to be tackled before modularization (temporary label, see #220) enhancement labels Aug 3, 2020
Copy link
Contributor

@mafiosso mafiosso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dist files and docs should be generated from scratch. I mean it should not be part of this commit as well as package.json diff. Currently I am not sure about planned functionality - see comments below. I tested this PR, tests are OK. I vote to merge this but I recommend to consider the notes below.

toDash : function( string, separator ){
separator = separator || '-';
if (typeof separator != 'string') throw new TypeError('Separator must be a string.');
if (separator.length != 1) throw new Error('Separator must be one character.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this restriction as artificial.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I only had a quick glance over the code, but this stood out to me, too.

camelCase : function( string, separator ){
separator = separator || '-';
if (typeof separator != 'string') throw new TypeError('Separator must be a string.');
if (separator.length != 1) throw new Error('Separator must be one character.');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find this restriction as artificial.

@@ -105,15 +105,21 @@
},

// Converts a string to camel case
camelCase : function( string ){
return string.replace(/-([a-z])/g, function (g) { return g[1].toUpperCase(); });
camelCase : function( string, separator ){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do we expect for inputs like "some----func" as result? Is it really some---Func, maybe input check for string would be fine. I suppose idempotence would be a good property here meaning that _.camelCase(_.camelCase(...(_.camelCase(x))...)) === _.camelCase(x) the same property should apply to the toDash function.

@jgonggrijp
Copy link
Contributor

@dpolac Would you like to dust off your PR and revise as indicated in the comments above? Otherwise, we can also do it for you. In either case, you'll get the credits for the commits you already made.

@jgonggrijp
Copy link
Contributor

@mafiosso Since @dpolac is not responding, I suggest that we take over. Would you like to do it? Otherwise I will.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
before modules This needs to be tackled before modularization (temporary label, see #220) enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants