String capitalization functions with special cases for certain ShipEngine words and phrases
npm install @shipengine/capitalizationShipEngine Capitalization
==============================================
String capitalization functions with special cases for certain ShipEngine words and phrases






Example
--------------------------
``javascript
import { snakeCase, pascalCase, titleCase } from "@shipengine/capitalization";
snakeCase("TheShipEngineSDKForWoocommerce"); // --> the_shipengine_sdk_for_woo_commerce
pascalCase("the_shipengine_sdk_for_woocommerce"); // --> TheShipEngineSdkForWooCommerce
titleCase("theShipengineSDKForWoocommerce"); // --> The ShipEngine SDK for WooCommerce
`
Installation
--------------------------
You can install ShipEngine Capitalization via npm.
`bash`
npm install @shipengine/capitalization
Usage
--------------------------
You can import the specific capitalization function(s) that you need to use:
`javascript`
import { kebabCase, camelCase, sentenceCase } from "@shipengine/capitalization";
Or you can import the entire capitalization module and use its methods:
`javascript
import capitalization from "@shipengine/capitalization";
capitalization.kebabCase("some text");
`
API
--------------------------
ShipEngine Capitalization exports several different capitalization functions, each of which accepts the same parameters:
- text - A string containing one or more words. The string can be in any format (snake case, camel case, pascal case, sentence case, etc.)
- options - An optional Options object
|Example inputs |Example outputs
|:-----------------------------------|:----------------------------------------------
|Hello, World! |hello_worldTheShipEngineAPI
| |the_shipengine_api
|Example inputs |Example outputs
|:-----------------------------------|:----------------------------------------------
|Hello, World! |hello-worldTheShipEngineAPI
| |the-shipengine-api
|Example inputs |Example outputs
|:-----------------------------------|:----------------------------------------------
|Hello, World! |helloWorldthis is the shipengine api
| |thisIsTheShipEngineApi
|Example inputs |Example outputs
|:-----------------------------------|:----------------------------------------------
|Hello, World! |HelloWorldthis is the shipengine api
| |ThisIsTheShipEngineApi
|Example inputs |Example outputs
|:-----------------------------------|:----------------------------------------------
|hello_world |Hello worldthis is the shipengine api
| |This is the ShipEngine API
|Example inputs |Example outputs
|:-----------------------------------|:----------------------------------------------
|hello_world |Hello Worldthis is the shipengine api
| |This is the ShipEngine API
|Option |Type |Default |Description
|:------------------|:----------------|:--------------------|:--------------------------------------------
|prefix |string |n/a |A prefix to be used when the result would otherwise be invalid due to starting with an illegal character.snakeCase("4x6 label")
For example, would throw an error because snake case strings cannot start with a number. But snakeCase("4x6 label", { prefix: "size" }) would return size_4x6_label.snakeCase("label size 4x6", { prefix: "size" })` would _not_ use the prefix.
Note: The prefix is only added when needed. So