Skip to content

sarscoder/alter-case

Repository files navigation

Alter Case

A utility for transforming string cases in javascript.

Why

JavaScript built-in methods for transforming string cases are limited to .toLowerCase() and .toUpperCase().

Installation

  • Install via a package manager npm or yarn
npm i alter-case

or

yarn add alter-case
  • Install via CDN
<!-- Minified Version -->
<script src="https://unpkg.com/alter-case@0.1.0/dist/index.min.js"></script>
<!-- Raw -->
<script src="https://unpkg.com/alter-case@0.1.0/dist/index.umd.js"></script>

Usage

alter-case come bundled with these functions:

camelCase

import { camelCase } from "alter-case";

camelCase("sample_text"); // sampleText

capitalCase

import { capitalCase } from "alter-case";

capitalCase("sample_text"); // Sample Text

constantCase

import { constantCase } from "alter-case";

constantCase("sample text"); // SAMPLE_TEXT

kebabCase

import { kebabCase } from "alter-case";

kebabCase("sample text"); // sample-text

pascalCase

import { pascalCase } from "alter-case";

pascalCase("sample text"); // SampleText

snakeCase

import { snakeCase } from "alter-case";

snakeCase("sample text"); // sample_text

lowerCase

import { lowerCase } from "alter-case";

// similar to javascript .toLowerCase()
lowerCase("Sample Text"); // sample text

upperCase

import { upperCase } from "alter-case";

// similar to javascript .toUpperCase()
upperCase("sample text"); // SAMPLE TEXT

License

MIT