Code Monkey home page Code Monkey logo

Comments (9)

blakeembrey avatar blakeembrey commented on May 18, 2024

This is intentional as-is. It's not clear how that is meant to change to cases such as param-case.

from change-case.

nmccready avatar nmccready commented on May 18, 2024

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.

nmccready avatar nmccready commented on May 18, 2024

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.

nmccready avatar nmccready commented on May 18, 2024

#19 is the same issue / related

from change-case.

blakeembrey avatar blakeembrey commented on May 18, 2024

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.

nmccready avatar nmccready commented on May 18, 2024

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.

blakeembrey avatar blakeembrey commented on May 18, 2024

It does sound like a good idea, yes!

from change-case.

demedos avatar demedos commented on May 18, 2024

+1 for optional noCase. When I used titleCase I didn't expect punctuation to be removed

from change-case.

blakeembrey avatar blakeembrey commented on May 18, 2024

A title-case that's unrelated to change-case has been released and should solve this for you.

from change-case.

Related Issues (20)

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.