Comments (9)
This is intentional as-is. It's not clear how that is meant to change to cases such as param-case
.
from change-case.
Same problem in titleCase
.
titleCase('TESTING with dash-es and a'postrophes')
- Expected
+ Received
- Testing With Dash-Es And A'Postrophes
+ Testing With Dash Es And A Postrophes
from change-case.
I see why this is happening due to noCase
, is it possible to make noCase
optional? NON_WORD_REGEXP
is the problem .
from change-case.
#19 is the same issue / related
from change-case.
I’d recommend using another library for this behavior for now. I’ll do a refactor at some point to clarify the name of this package.
from change-case.
When you refactor are you considering using lerna
as it would help immensely with the micro repos.
export const titleWithPunc = (words, { doLowerRest = true, splitter = /[^\d\s]+/g } = {}) =>
words.replace(splitter, (word) => {
let rest = word.substr(1);
if (doLowerRest) {
rest = rest.toLowerCase();
}
return word.charAt(0).toUpperCase() + rest;
});
import { titleWithPunc } from './changeCase';
describe('ourChangeCase', () => {
describe(titleWithPunc.name, () => {
it('single word', () => expect(titleWithPunc('crap')).toEqual('Crap'));
it('two words', () => expect(titleWithPunc('crap beer')).toEqual('Crap Beer'));
describe('keeps punctuation', () => {
it('keeps punc', () =>
expect(titleWithPunc(`crap bEER's #1 baby some-dash #2hi`)).toEqual(
`Crap Beer's #1 Baby Some-dash #2Hi`
));
it('keeps punc', () =>
expect(
titleWithPunc(`crap bEER's #1 baby some-dash #2hi`, { doLowerRest: false })
).toEqual(`Crap BEER's #1 Baby Some-dash #2Hi`));
});
});
});
from change-case.
It does sound like a good idea, yes!
from change-case.
+1 for optional noCase
. When I used titleCase
I didn't expect punctuation to be removed
from change-case.
A title-case
that's unrelated to change-case
has been released and should solve this for you.
from change-case.
Related Issues (20)
- `title-case` capitalizes "from" (to "From") HOT 3
- title-case: a quoted word with a period in it doesn't get capitalized
- capitalCase when single number HOT 1
- Consider a new release
- param case with numbers as strings resulting in snake case? HOT 1
- Title Case not working with a camelCase string HOT 3
- sentenceCase function replaces non-English alphabets with whitespace HOT 1
- Why are tslib and typescript dependencies of these libraries? HOT 2
- Provide a custom array of additions to the lowercase words? HOT 1
- Sentence case HOT 1
- More lightweight solution
- VSCode extension alternatives
- Convert string to lowercase prior to processing HOT 3
- Could noCase package support Chinese word HOT 1
- Invalid or Unexpected Token on SUPPORTED LOCALES for change-case HOT 6
- Characater problem HOT 2
- brackets are removed from tite HOT 1
- Apostrophe not supported HOT 1
- TypeScript template literal support (`const camel: "fooBar" = camelCase("foo_bar")`) HOT 1
- Any interest in shipping ESM? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from change-case.