Kasi
A collection of functions for working with different casings.
Install
npm install --save kasi
Functions
Check
These functions allow you to check if a string is using a specific casing.
isCamelCase
import {isCamelCase} from 'kasi';
isCamelCase ( 'fooBar' );
isCamelCase ( 'foo-bar' );
isConstantCase
import {isConstantCase} from 'kasi';
isConstantCase ( 'FOO_BAR' );
isConstantCase ( 'fooBar' );
isDotCase
import {isDotCase} from 'kasi';
isDotCase ( 'foo.bar' );
isDotCase ( 'fooBar' );
isKebabCase
import {isKebabCase} from 'kasi';
isKebabCase ( 'foo-bar' );
isKebabCase ( 'fooBar' );
isLowerCase
import {isLowerCase} from 'kasi';
isLowerCase ( 'foo' );
isLowerCase ( 'Foo' );
isPascalCase
import {isPascalCase} from 'kasi';
isPascalCase ( 'FooBar' );
isPascalCase ( 'fooBar' );
isPathCase
import {isPathCase} from 'kasi';
isPathCase ( 'foo/bar' );
isPathCase ( 'fooBar' );
isSnakeCase
import {isSnakeCase} from 'kasi';
isSnakeCase ( 'foo_bar' );
isSnakeCase ( 'fooBar' );
isTitleCase
import {isTitleCase} from 'kasi';
isTitleCase ( 'Foo Bar' );
isTitleCase ( 'fooBar' );
isUpperCase
import {isUpperCase} from 'kasi';
isUpperCase ( 'FOO' );
isUpperCase ( 'foo' );
Convert
These functions allow you to convert a string to a specific casing.
toCamelCase
import {toCamelCase} from 'kasi';
toCamelCase ( 'foo-bar' );
toCamelCase ( 'foo_bar' );
toConstantCase
import {toConstantCase} from 'kasi';
toConstantCase ( 'fooBar' );
toConstantCase ( 'foo-bar' );
toDotCase
import {toDotCase} from 'kasi';
toDotCase ( 'fooBar' );
toDotCase ( 'foo-bar' );
toKebabCase
import {toKebabCase} from 'kasi';
toKebabCase ( 'fooBar' );
toKebabCase ( 'foo_bar' );
toLowerCase
import {toLowerCase} from 'kasi';
toLowerCase ( 'FooBar' );
toLowerCase ( 'foo-bar' );
toPascalCase
import {toPascalCase} from 'kasi';
toPascalCase ( 'foo-bar' );
toPascalCase ( 'foo_bar' );
toPathCase
import {toPathCase} from 'kasi';
toPathCase ( 'fooBar' );
toPathCase ( 'foo-bar' );
toSnakeCase
import {toSnakeCase} from 'kasi';
toSnakeCase ( 'fooBar' );
toSnakeCase ( 'foo-bar' );
toTitleCase
import {toTitleCase} from 'kasi';
toTitleCase ( 'fooBar' );
toTitleCase ( 'foo-bar' );
toUpperCase
import {toUpperCase} from 'kasi';
toUpperCase ( 'fooBar' );
toUpperCase ( 'foo-bar' );
These extra functions perform other operations related to casings.
apply
Transform a string to the given casing. Useful in combination with detect
.
import {apply} from 'kasi';
apply ( 'foo-bar', 'camel' );
apply ( 'foo-bar', 'constant' );
copy
This function copies the casing of a string to another string, character by character. The two strings must have the same length.
import {copy} from 'kasi';
copy ( 'sIlLy', 'lions' );
copy ( 'SiLlY', 'lions' );
detect
This function detects the casing of a string. Useful in combination with apply
.
import {detect} from 'kasi';
detect ( 'fooBar' );
detect ( 'FOO_BAR' );
detect ( ' foo BAR ' );
License
MIT © Fabio Spampinato