Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (naming-converter) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Naming Converter
A package for converting object keys and strings between different case types (camelCase, PascalCase, kebab-case, snake_case).
Installation
Install the package using npm:
npm install naming-converterAPI
Factory for String Converter
createStringConverter
Creates a new instance of the string converter.
createStringConverter(fromCase: CaseType, toCase: CaseType): StringConverter;Parameters
fromCase- The case type of the input string.toCase- The case type of the output string.
Returns
A new instance of the string converter.
Usage
import { createStringConverter } from "naming-converter/factory/create-string-converter";
import { CaseType } from "naming-converter/shared/models/definitions";
const stringConverter = createStringConverter(
CaseType.CAMEL_CASE,
CaseType.KEBAB_CASE
);
const camelCaseString = "camelCaseString";
const kebabCaseString = stringConverter.convert(camelCaseString);
console.log(kebabCaseString); // Output: camel-case-stringFactory for Object Converter
createObjectConverter
Creates a new instance of the object converter.
createObjectConverter(fromCase: CaseType, toCase: CaseType): ObjectConverter;Parameters
fromCase- The case type of the input object.toCase- The case type of the output object.
Returns
A new instance of the object converter.
Usage
import { createObjectConverter } from "naming-converter/factory/create-object-converter";
import { CaseType } from "naming-converter/shared/models/definitions";
const objectConverter = createObjectConverter(
CaseType.CAMEL_CASE,
CaseType.KEBAB_CASE
);
const camelCaseObject = {
camelCaseKey: "example",
};
const kebabCaseObject = objectConverter.convert(camelCaseObject);
console.log(kebabCaseObject); // Output: { "camel-case-key": "example" }License
This project is licensed under the MIT License - see the LICENSE file for details.