@trenskow/caseit

1.3.12 • Public • Published

@trenskow/caseit

A small library for changing the case of a string.

Usage

Import using the following example.

const caseit = require('@trenskow/caseit');

– or

import caseit from '@trenskow/caseit'

Converting

To convert from one case type to another use the following example.

const myCamelCase = caseit('my_camel_case', 'camel'); // return 'myCamelCase';

You can convert from any format to any other format. Supported formats are.

  • camel - camelCase
  • pascal - PascalCase
  • snake - snake_case
  • domain - domain.case
  • kebab - kebab-case
  • title - Title Case
  • http - Http-Case

Default format (if omitted) is camel (because it is the Javascript default).

Detecting

To detect the casing of a string do as the following example.

caseit.detect('MyCase'); // returns ['pascal']
caseit.detect('Hello'); // returns ['pascal', 'title', 'http']

Getting the words

You can also get the lowercase variants of all the words in a string by using the following example.

caseit.words('MyCase'); // returns ['my', 'case']

LICENSE

3-Clause BSD (see LICENSE).

Dependents (8)

Package Sidebar

Install

npm i @trenskow/caseit

Weekly Downloads

1

Version

1.3.12

License

BSD-2-Clause

Unpacked Size

5.13 kB

Total Files

5

Last publish

Collaborators

  • trenskow