Code Monkey home page Code Monkey logo

change-case's People

Contributors

aayush123 avatar abdelrahman-elkady avatar alarner avatar azu avatar blakeembrey avatar dcrockwell avatar dependabot[bot] avatar galenhuntington avatar greenkeeper[bot] avatar greenkeeperio-bot avatar linkvt avatar marcingajda avatar mvargeson avatar nrabins avatar ntnyq avatar patrik-csak avatar quicksaver avatar realityking avatar romansj avatar shinigami92 avatar syntactic-salt avatar trysound avatar uladkasach avatar whoaa512 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

change-case's Issues

paramCase inconsistencies

The documentation for paramCase disagrees with the code and tests.

Which is correct? Are you going to change the documentation or the implementation?

Thanks!

Changelog for major release

Hi Blake,

thank you for maintaining all these small, focused packages.

I wonder if you keep track of changes between releases somewhere? I've looked around but couldn't find them. I'm in particular interested in the breaking changes of `pascal-case@v3'

Support tree-shaking with `import { camelCase } from 'change-case'`

Hello.
I never write require(' ') in my apps, so I'm not sure their support for tree-shaking.
But with the official ES import method:

import { camelCase } from 'change-case'

this would allow webpack and rollup to tree-shake the 'change-case' package to only include camelCase for example.

Is this possible with your package as well?

Title case incorrectly capitalizing some words.

If we were to follow a style guide like "The Chicago Manual of Style" then the tile case rules would be as follows:

The following rules, though occasionally arbitrary, are intended primarily to facilitate the consistent styling of titles mentioned or cited in text and notes:

  1. Capitalize the first and last words in titles and subtitles (but see rule 7), and capitalize all other major words (nouns, pronouns, verbs, adjectives, adverbs, and some conjunctions—but see rule 4).
  2. Lowercase the articles the, a, and an.
  3. Lowercase prepositions, regardless of length, except when they are used adverbially or adjectivally (up in Look Up, down in Turn Down, on in The On Button, to in Come To, etc.) or when they compose part of a Latin expression used adjectivally or adverbially (De Facto, In Vitro, etc.).
  4. Lowercase the common coordinating conjunctions and, but, for, or, and nor.
  5. Lowercase to not only as a preposition (rule 3) but also as part of an infinitive (to Run, to Hide, etc.), and lowercase as in any grammatical function.
  6. Lowercase the part of a proper name that would be lowercased in text, such as de or von.
  7. Lowercase the second part of a species name, such as fulvescens in Acipenser fulvescens, even if it is the last word in a title or subtitle.

http://www.chicagomanualofstyle.org/book/ed17/part2/ch08/psec159.html

Some examples at http://www.chicagomanualofstyle.org/book/ed17/part2/ch08/psec160.html

Mnemonics That Work Are Better Than Rules That Do Not
Singing While You Work
A Little Learning Is a Dangerous Thing (2)
Four Theories concerning the Gospel according to Matthew (2, 3)
Taking Down Names, Spelling Them Out, and Typing Them Up (3, 4)
Tired but Happy (4)

I'd suggest, for ease, a subset of those rules be implemented. Perhaps algorithmically something like the following (corresponding roughly to the above rules):

  • \1. Capitalize all words in the string.
  • \2. Lowercase the articles the, a, and an (not in a first or last position).
  • \4. Lowercase the common coordinating conjunctions and, but, for, or, and nor (not in a first or last position).

Edit: Added "(not in a first or last position)" clause to suggested algorithm.

Snake case underscore before numbers

At the moment, snakeCase doesn't insert an underscore before numbers. I would expect it to do that.

Current behaviour:
changeCase.snakeCase("pricePer100Km") returns price_per100_km.

Expected behaviour:
changeCase.snakeCase("pricePer100Km") returns price_per_100_km.

If this is not a bug, then I would suggest making it an option through a possible argument. Maybe like this:

changeCase.snakeCase("pricePer100Km", {handleNumbers: true}) returns price_per_100_km.

Centralize CHANGELOG

Due to how Lerna works (and refuses to change), when a patch changes it publishes all dependents with patches also. This creates a lot of release noise. Need to investigate how this could either be eliminated, or bundled into a single release for simpler documenting of the change.

For now, the convention I'll follow is that undocumented releases were only patches and do not contain any note worthy changes.

add lcFirst function

It would be nice to have a lcFirst function.
This is needed for example to convert an object name to a variable in angular.

For example i want to convert SearchService object into searchService variable.

It is easy to craft a function of the type:

function firstCharLowercase(string) {
    return  string.charAt(0).toLowerCase() + string.slice(1);

}

but it would be nicer to have it here because already an ucfirst function exists :-)

Add default export to packages

Since v3, require('snake-case') and others no longer return a function:

$ node
> require('snake-case')
{ snakeCase: [Function: snakeCase] }

Is that by design?

data with numbers in it

I have a string "amazon s3 data" that I have pushed through paramCase. The result is "amazon-s-3-data" , where I really wanted "amazon-s3-data"

is there any way of doing this, or will I have to do some manipulation myself ?

lol I was looking for PacalCase

and couldn't find it. Five minutes later I realized that it is pascalCase.

Funny cognitive dissonance.

Thanks for this library Blake!

Ge

Doesn't work with browserify

Keeps saying it can't find module dot-case, upon inspecting the code I believe it has to do with how you require each dependency in the loop. browserify is statically analyzing the module so it doesn't complete the dependency graph.

Convert to support es2015

This applies to all sub-packages (I am using pascal-case and param-case directly).

Currently, es2016 syntax doesn't work:

import * as changeCase from 'change-case'

image

Shouldn't sentence case lead with an uppercase letter?

I.e:

changeCase.sentence('whaleShark') // -> 'Whale shark'

This isn't particularly significant for what I'm doing (generating a friendly name for a model type to use in an error message), but I was curious to know whether my suspicion is correct or not :)

Version 4: camelcase merge numbers option removed?

This is more of a question rather than an issue. In version 3.x, we used the mergeNumbers option when invoking camelCase, example:

const camelCase('some_field_1', '', true); // -> someField1

Since upgrading to version 4, it looks like the options accepted by camelCase have been centralised, and this feature has been lost, is this correct?

Is there a recommended way to achieve the above with version 4?

bower.json

I want to use this lib in my frontend, using bower - do you have a build script that would create a single dist file, or will I have to roll my own ?

Leading underscores are not preserved

First off, thanks for the lib, it's fantastic! 😄

So, leading underscores are not preserved (even with snakeCase):

changeCase.snakeCase('private');  //=> 'private'
changeCase.snakeCase('_private'); //=> 'private'
changeCase.snakeCase('private_key');  //=> 'private_key'
changeCase.snakeCase('_private_key'); //=> 'private_key'
changeCase.snakeCase('privateKey');  //=> 'private_key'
changeCase.snakeCase('_privateKey'); //=> 'private_key'

changeCase.camelCase('private_key');  //=> 'privateKey'
changeCase.camelCase('_private_key'); //=> 'privateKey'

There's a strong argument to be made that this is expected behavior for camelCase specifically, but I think for snakeCase it is arguably not expected behavior; leading underscores are pretty widely used as a convention to denote privacy, and the presence of a leading underscore doesn't conflict with the rules of "snake case", unless I'm mistaken.

Thoughts?

If this is intended behavior/"wontfix", would you consider an option parameter to preserve leading underscores?

where is upperCaseFirst?

Did you deliberately remove the upperCaseFirst functionality or is it hidden somewhere else now?

ucFirst removed ?

 import { ucFirst } from 'change-case';

Updated from 3.1.0 to 4.0.0.
Why removing function instead of deprecation?

Also it's not clear how to import upperCaseFirst.

Regression: change-case v4 no longer accepts `undefined`

Consider the following code:

require('change-case').camelCase()

Using change-case version 3.x (3.1.0), this code works and returns and empty string ''.

Using change-case version 4.x (4.0.0), this code throws the following error:

TypeError: Cannot read property 'replace' of undefined
    at Object.noCase (node_modules/no-case/dist/index.js:14:10)
    at Object.pascalCase (node_modules/pascal-case/dist/index.js:15:22)
    at Object.camelCase (node_modules/camel-case/dist/index.js:11:26)

Assuming this new behavior is intended: can we document the change in release notes please?

Add the option to chain methods

A good enhancement IMO would be to be able to do something like:

changeCase('someWord').chain()
  .toSnakeCase()
  .firstUpperCase()
  ...
  .value()

If it's a good idea I can create a pull request to add that.

abbreviations-aware camel case

I would love to have camel case - or any other transformations from upper case to lower case - to take abbreviations into account. The list of abbreviations can be passed as a paramter.

Does not preserve $

With PHP, variables start with the $ character. It would be great if this character was not stripped by change-case.

For instance:
$postID becomes post_id instead of $post_id

Header-Case?

For going from whatever-case to Title-Case-With-Hyphens for use in things like HTTP headers:

contentType -> Content-Type
ccRequestType -> CC-Request-Type

Consider adding "title_snake_case" or similar.

I just ran into a situation where I had a bunch of (lowercase) snake_case symbols and needed each word to be in title case. Sadly change-case does not handle this flavor. For example, I want to be able to transform some_thing into Some_Thing. I know this is a little uncommon but it would have been very helpful just now!

I am using change-case via the VSCode extension and it is tremendously useful. Thanks for the great library!

Numeric values in pascalCase.

Given this code

var cs = require('change-case')
cs.pascal('something2014other')

I would assume the result to be Something2014Other, not Something2014other.

Same goes for camel casing.

Calling camelCase on string that's already camel cased

Ran into an issue trying to normalise some strings. Trying to camelCase a string that's camel cased and contains two words works as expected:

changeCase.camelCase("fooBar");
// outputs fooBar

More than three words seems to break it though:

changeCase.camelCase("fooBarBaz");
// outputs fooBarbaz

Core bug with latest release

  Error thrown in test:

  TypeError {
    message: 'Cannot destructure property `splitRegexp` of \'undefined\' or \'null\'.',
  }

  noCase (node_modules/no-case/src/index.ts:20:9)
  maskString (src/index.js:199:25)
  maskProps (src/index.js:253:18)
  parseRequest (src/index.js:400:12)
  test/basic.js:518:15

Identify case of string?

Would be nice to identify case of string, eg:

change-case.identifyCase("Love"); -> titleCase
change-case.identifyCase("LOVE"); -> All Uppercase
etc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.