uncase
Version:
Wrapper of change-case to create case converter, validator and etc.
57 lines (56 loc) • 2.03 kB
TypeScript
import { CaseValidator, isCamelCase, isCapitalCase, isConstantCase, isDotCase, isKebabCase, isNoCase, isPascalCase, isPascalSnakeCase, isPathCase, isSentenceCase, isSnakeCase, isTrainCase } from "./is-CS1bKTh4.js";
import { Options } from "change-case";
export * from "change-case";
//#region src/core.d.ts
/**
* Case converter
*/
type CaseConverter = (input: string) => CaseConvertResult;
/**
* Case convert result
*/
type CaseConvertResult = {
/**
* whether output has changed from input
*/
changed: boolean;
/**
* input value
*/
input: string;
/**
* converted value
*/
output: string;
};
/**
* All case converter names in raw and `camelCase`
*/
type CaseType = "camelCase" | "capitalCase" | "Capital Case" | "CONSTANT_CASE" | "constantCase" | "dot.case" | "dotCase" | "kebab-case" | "kebabCase" | "noCase" | "no case" | "Pascal_Snake_Case" | "pascalCase" | "PascalCase" | "pascalSnakeCase" | "path/case" | "pathCase" | "sentenceCase" | "Sentence case" | "snake_case" | "snakeCase" | "Train-Case" | "trainCase";
/**
* CaseType to case converter map
*/
declare const convertersMap: Record<CaseType, (value: string, options?: Options) => string>;
/**
* Get a converter by caseType and convert the given input
*
* @param caseType - case utils name
* @param options - case utils options
* @returns case convert result {@link CaseConvertResult}
*
* @see {@link https://github.com/blakeembrey/change-case}
*
* @example
*
* ```ts
* import { getCaseConverter } from 'uncase'
*
* const result = getCaseConverter('camelCase')('hello-world')
*
* console.log(result)
* // => { input: 'hello-world', changed: true, output: 'helloWorld' }
* ```
*/
declare function getCaseConverter(caseType: CaseType, options?: Options): CaseConverter;
//#endregion
export { CaseConvertResult, CaseConverter, CaseType, CaseValidator, convertersMap, getCaseConverter, isCamelCase, isCapitalCase, isConstantCase, isDotCase, isKebabCase, isNoCase, isPascalCase, isPascalSnakeCase, isPathCase, isSentenceCase, isSnakeCase, isTrainCase };