GithubHelp home page GithubHelp logo

justjavac / deno-change-case Goto Github PK

View Code? Open in Web Editor NEW
15.0 2.0 2.0 46 KB

Convert strings between camelCase, PascalCase, Title Case, snake_case and more

Home Page: https://deno.land/x/case

License: MIT License

TypeScript 100.00%
deno string case-converter camelcase pascalcase snakecase

deno-change-case's Introduction

Change Case

Convert strings between camelCase, PascalCase, Title Case, snake_case, lowercase, UPPERCASE, CONSTANT_CASE and more.

All methods support Unicode (non-ASCII characters) and non-string entities, such as objects with a toString property, numbers and booleans. Empty values (null and undefined) will result in an empty string.

Source code based on blakeembrey/change-case with TypeScript.

Usage

import { camelCase } from "https://deno.land/x/case/mod.ts";
camelCase("test string");
// => 'testString'

or

import camelCase from "https://deno.land/x/case/camelCase.ts";
camelCase("test string");
// => 'testString'

Available methods (short-hand shown below, long-hand available in examples):

All methods accept two arguments, the string to change case and an optional locale.

camelCase

Return as a string with the separators denoted by having the next letter capitalized.

camelCase("test string");
//=> "testString"

constantCase

Return as an upper case, underscore separated string.

constantCase("test string");
//=> "TEST_STRING"

dotCase

Return as a lower case, period separated string.

dotCase("test string");
//=> "test.string"

headerCase

Return as a title cased, dash separated string.

headerCase("test string");
//=> "Test-String"

lowerCase

Return the string in lower case.

lowerCase("TEST STRING");
//=> "test string"

lowerFirstCase

Return the string with the first character lower cased.

lowerFirstCase("TEST");
//=> "tEST"

normalCase

  • no
  • clear

Return the string without any casing (lower case, space separated).

normalCase("test string");
//=> "test string"

paramCase

Aliases

  • kebabCase
  • hyphenCase

Return as a lower case, dash separated string.

paramCase("test string");
//=> "test-string"

pascalCase

Return as a string denoted in the same fashion as camelCase, but with the first letter also capitalized.

pascalCase("test string");
//=> "TestString"

pathCase

Return as a lower case, slash separated string.

pathCase("test string");
//=> "test/string"

sentenceCase

Return as a lower case, space separated string with the first letter upper case.

sentenceCase("testString");
//=> "Test string"

snakeCase

Return as a lower case, underscore separated string.

snakeCase("test string");
//=> "test_string"

swapCase

Return as a string with every character case reversed.

swapCase("Test String");
//=> "tEST sTRING"

titleCase

Return as a space separated string with the first character of every word upper cased.

titleCase("a simple test");
//=> "A Simple Test"

upperCase

Return the string in upper case.

upperCase("test string");
//=> "TEST STRING"

upperFirstCase

Return the string with the first character upper cased.

upperFirstCase("test");
//=> "Test"

Credits

License

deno-change-case is released under the MIT License. See the bundled LICENSE file for details.

deno-change-case's People

Contributors

chances avatar justjavac avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

chances shopstic

deno-change-case's Issues

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.