Coder Social home page Coder Social logo

amirkabiri / camelcase Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sindresorhus/camelcase

0.0 0.0 0.0 74 KB

Convert a dash/dot/underscore/space separated string to camelCase: foo-bar → fooBar

License: MIT License

JavaScript 96.58% TypeScript 3.42%

camelcase's Introduction

camelcase

Convert a dash/dot/underscore/space separated string to camelCase or PascalCase: foo-barfooBar

Correctly handles Unicode strings.

If you use this on untrusted user input, don't forget to limit the length to something reasonable.

Install

npm install camelcase

Usage

import camelCase from 'camelcase';

camelCase('foo-bar');
//=> 'fooBar'

camelCase('foo_bar');
//=> 'fooBar'

camelCase('Foo-Bar');
//=> 'fooBar'

camelCase('розовый_пушистый_единорог');
//=> 'розовыйПушистыйЕдинорог'

camelCase('foo bar');
//=> 'fooBar'

console.log(process.argv[3]);
//=> '--foo-bar'
camelCase(process.argv[3]);
//=> 'fooBar'

camelCase(['foo', 'bar']);
//=> 'fooBar'

camelCase(['__foo__', '--bar']);
//=> 'fooBar'

API

camelCase(input, options?)

input

Type: string | string[]

The string to convert to camel case.

options

Type: object

pascalCase

Type: boolean
Default: false

Uppercase the first character: foo-barFooBar

import camelCase from 'camelcase';

camelCase('foo-bar', {pascalCase: true});
//=> 'FooBar'

camelCase('foo-bar', {pascalCase: false});
//=> 'fooBar'
preserveConsecutiveUppercase

Type: boolean
Default: false

Preserve consecutive uppercase characters: foo-BARFooBAR

import camelCase from 'camelcase';

camelCase('foo-BAR', {preserveConsecutiveUppercase: true});
//=> 'fooBAR'

camelCase('foo-BAR', {preserveConsecutiveUppercase: false});
//=> 'fooBar'
locale

Type: false | string | string[]
Default: The host environment’s current locale.

The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an array, the best available locale is used.

import camelCase from 'camelcase';

camelCase('lorem-ipsum', {locale: 'en-US'});
//=> 'loremIpsum'

camelCase('lorem-ipsum', {locale: 'tr-TR'});
//=> 'loremİpsum'

camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB']});
//=> 'loremIpsum'

camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
//=> 'loremİpsum'

Setting locale: false ignores the platform locale and uses the Unicode Default Case Conversion algorithm:

import camelCase from 'camelcase';

// On a platform with `tr-TR`.

camelCase('lorem-ipsum');
//=> 'loremİpsum'

camelCase('lorem-ipsum', {locale: false});
//=> 'loremIpsum'

Related

camelcase's People

Contributors

ambujsahu81 avatar amirkabiri avatar bendingbender avatar coreyfarrell avatar danielseehausen avatar davidepastore avatar dcousens avatar fdawgs avatar forresst avatar jcrandall101 avatar jhnns avatar kevva avatar lokua avatar mesaugat avatar nam-hle avatar ntwb avatar pedromiguelss avatar qix- avatar qw-in avatar rasgele avatar rocktimsaikia avatar samverschueren avatar semigradsky avatar sindresorhus avatar skavigitp avatar stringparser avatar sverweij avatar tychenjiajun avatar yuler avatar

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.