JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 35253
  • Score
    100M100P100Q138178F

A collection of functions for working with different casings.

Package Exports

  • kasi

Readme

Kasi

A collection of functions for working with different casings.

Install

npm install --save kasi

Functions

Check Convert Extra
isCamelCase toCamelCase apply
isConstantCase toConstantCase copy
isKebabCase toKebabCase detect
isLowerCase toLowerCase
isPascalCase toPascalCase
isSnakeCase toSnakeCase
isUpperCase toUpperCase

Check

These functions allow you to check if a string is using a specific casing.

isCamelCase

import {isCamelCase} from 'kasi';

isCamelCase ( 'fooBar' ); // => true
isCamelCase ( 'foo-bar' ); // => false

isConstantCase

import {isConstantCase} from 'kasi';

isConstantCase ( 'FOO_BAR' ); // => true
isConstantCase ( 'fooBar' ); // => false

isKebabCase

import {isKebabCase} from 'kasi';

isKebabCase ( 'foo-bar' ); // => true
isKebabCase ( 'fooBar' ); // => false

isLowerCase

import {isLowerCase} from 'kasi';

isLowerCase ( 'foo' ); // => true
isLowerCase ( 'Foo' ); // => false

isPascalCase

import {isPascalCase} from 'kasi';

isPascalCase ( 'FooBar' ); // => true
isPascalCase ( 'fooBar' ); // => false

isSnakeCase

import {isSnakeCase} from 'kasi';

isSnakeCase ( 'foo_bar' ); // => true
isSnakeCase ( 'fooBar' ); // => false

isUpperCase

import {isUpperCase} from 'kasi';

isUpperCase ( 'FOO' ); // => true
isUpperCase ( 'foo' ); // => false

Convert

These functions allow you to convert a string to a specific casing.

toCamelCase

import {toCamelCase} from 'kasi';

toCamelCase ( 'foo-bar' ); // => 'fooBar'
toCamelCase ( 'foo_bar' ); // => 'fooBar'

toConstantCase

import {toConstantCase} from 'kasi';

toConstantCase ( 'fooBar' ); // => 'FOO_BAR'
toConstantCase ( 'foo-bar' ); // => 'FOO_BAR'

toKebabCase

import {toKebabCase} from 'kasi';

toKebabCase ( 'fooBar' ); // => 'foo-bar'
toKebabCase ( 'foo_bar' ); // => 'foo-bar'

toLowerCase

import {toLowerCase} from 'kasi';

toLowerCase ( 'FooBar' ); // => 'foobar'
toLowerCase ( 'foo-bar' ); // => 'foo-bar'

toPascalCase

import {toPascalCase} from 'kasi';

toPascalCase ( 'foo-bar' ); // => 'FooBar'
toPascalCase ( 'foo_bar' ); // => 'FooBar'

toSnakeCase

import {toSnakeCase} from 'kasi';

toSnakeCase ( 'fooBar' ); // => 'foo_bar'
toSnakeCase ( 'foo-bar' ); // => 'foo_bar'

toUpperCase

import {toUpperCase} from 'kasi';

toUpperCase ( 'fooBar' ); // => 'FOOBAR'
toUpperCase ( 'foo-bar' ); // => 'FOO-BAR'

Extra

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' ); // => 'fooBar'
apply ( 'foo-bar', 'constant' ); // => 'FOO_BAR'

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' ); // => 'lIoNs'
copy ( 'SiLlY', 'lions' ); // => 'LiOnS'

detect

This 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'

License

MIT © Fabio Spampinato