$ gnpm install kasi
A collection of functions for working with different casings.
npm install --save kasi
These functions allow you to check if a string is using a specific casing.
isCamelCaseimport {isCamelCase} from 'kasi';
isCamelCase ( 'fooBar' ); // => true
isCamelCase ( 'foo-bar' ); // => false
isConstantCaseimport {isConstantCase} from 'kasi';
isConstantCase ( 'FOO_BAR' ); // => true
isConstantCase ( 'fooBar' ); // => false
isDotCaseimport {isDotCase} from 'kasi';
isDotCase ( 'foo.bar' ); // => true
isDotCase ( 'fooBar' ); // => false
isKebabCaseimport {isKebabCase} from 'kasi';
isKebabCase ( 'foo-bar' ); // => true
isKebabCase ( 'fooBar' ); // => false
isLowerCaseimport {isLowerCase} from 'kasi';
isLowerCase ( 'foo' ); // => true
isLowerCase ( 'Foo' ); // => false
isPascalCaseimport {isPascalCase} from 'kasi';
isPascalCase ( 'FooBar' ); // => true
isPascalCase ( 'fooBar' ); // => false
isPathCaseimport {isPathCase} from 'kasi';
isPathCase ( 'foo/bar' ); // => true
isPathCase ( 'fooBar' ); // => false
isSnakeCaseimport {isSnakeCase} from 'kasi';
isSnakeCase ( 'foo_bar' ); // => true
isSnakeCase ( 'fooBar' ); // => false
isTitleCaseimport {isTitleCase} from 'kasi';
isTitleCase ( 'Foo Bar' ); // => true
isTitleCase ( 'fooBar' ); // => false
isUpperCaseimport {isUpperCase} from 'kasi';
isUpperCase ( 'FOO' ); // => true
isUpperCase ( 'foo' ); // => false
These functions allow you to convert a string to a specific casing.
toCamelCaseimport {toCamelCase} from 'kasi';
toCamelCase ( 'foo-bar' ); // => 'fooBar'
toCamelCase ( 'foo_bar' ); // => 'fooBar'
toConstantCaseimport {toConstantCase} from 'kasi';
toConstantCase ( 'fooBar' ); // => 'FOO_BAR'
toConstantCase ( 'foo-bar' ); // => 'FOO_BAR'
toDotCaseimport {toDotCase} from 'kasi';
toDotCase ( 'fooBar' ); // => 'foo.bar'
toDotCase ( 'foo-bar' ); // => 'foo.bar'
toKebabCaseimport {toKebabCase} from 'kasi';
toKebabCase ( 'fooBar' ); // => 'foo-bar'
toKebabCase ( 'foo_bar' ); // => 'foo-bar'
toLowerCaseimport {toLowerCase} from 'kasi';
toLowerCase ( 'FooBar' ); // => 'foobar'
toLowerCase ( 'foo-bar' ); // => 'foo-bar'
toPascalCaseimport {toPascalCase} from 'kasi';
toPascalCase ( 'foo-bar' ); // => 'FooBar'
toPascalCase ( 'foo_bar' ); // => 'FooBar'
toPathCaseimport {toPathCase} from 'kasi';
toPathCase ( 'fooBar' ); // => 'foo/bar'
toPathCase ( 'foo-bar' ); // => 'foo/bar'
toSnakeCaseimport {toSnakeCase} from 'kasi';
toSnakeCase ( 'fooBar' ); // => 'foo_bar'
toSnakeCase ( 'foo-bar' ); // => 'foo_bar'
toTitleCaseimport {toTitleCase} from 'kasi';
toTitleCase ( 'fooBar' ); // => 'Foo Bar'
toTitleCase ( 'foo-bar' ); // => 'Foo Bar'
toUpperCaseimport {toUpperCase} from 'kasi';
toUpperCase ( 'fooBar' ); // => 'FOOBAR'
toUpperCase ( 'foo-bar' ); // => 'FOO-BAR'
These extra functions perform other operations related to casings.
applyTransform a string to the given casing. Useful in combination with detect.
import {apply} from 'kasi';
apply ( 'foo-bar', 'camel' ); // => 'fooBar'
apply ( 'foo-bar', 'constant' ); // => 'FOO_BAR'
copyThis 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' ); // => 'lIoNs'
copy ( 'SiLlY', 'lions' ); // => 'LiOnS'
detectThis function detects the casing of a string. Useful in combination with apply.
import {detect} from 'kasi';
detect ( 'fooBar' ); // => 'camel'
detect ( 'FOO_BAR' ); // => 'constant'
detect ( ' foo BAR ' ); // => 'unknown'
MIT © Fabio Spampinato
Copyright 2013 - present © cnpmjs.org | Home |