npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@shipengine/capitalization

v1.2.1

Published

String capitalization functions with special cases for certain ShipEngine words and phrases

Downloads

973

Readme

ShipEngine Capitalization

String capitalization functions with special cases for certain ShipEngine words and phrases

Cross-Platform Compatibility Build Status

Coverage Status Dependencies

npm License

Example

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.

npm install @shipengine/capitalization

Usage

You can import the specific capitalization function(s) that you need to use:

import { kebabCase, camelCase, sentenceCase } from "@shipengine/capitalization";

Or you can import the entire capitalization module and use its methods:

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

snakeCase(text, [options])

Snake case strings are all lowercase with underscores as word separators. No whitespace or punctuation characters are allowed, and the string must begin with a letter.

|Example inputs |Example outputs |:-----------------------------------|:---------------------------------------------- |Hello, World! |hello_world |TheShipEngineAPI |the_shipengine_api

kebabCase(text, [options])

Kebab case strings are all lowercase with hyphens as word separators. No whitespace or punctuation characters are allowed, and the string must begin with a letter.

|Example inputs |Example outputs |:-----------------------------------|:---------------------------------------------- |Hello, World! |hello-world |TheShipEngineAPI |the-shipengine-api

camelCase(text, [options])

Camel case strings use capitalization as word separators. Each new word begins with a capital letter, followed by lowercase letters. No whitespace or punctuation characters are allowed, and the string must begin with a lowercase letter.

|Example inputs |Example outputs |:-----------------------------------|:---------------------------------------------- |Hello, World! |helloWorld |this is the shipengine api |thisIsTheShipEngineApi

pascalCase(text, [options])

Pascal case strings use capitalization as word separators. Each new word begins with a capital letter, followed by lowercase letters. No whitespace or punctuation characters are allowed, and the string must begin with an uppercase letter.

|Example inputs |Example outputs |:-----------------------------------|:---------------------------------------------- |Hello, World! |HelloWorld |this is the shipengine api |ThisIsTheShipEngineApi

sentenceCase(text, [options])

Sentence case strings follow basic English sentence rules. Words are separated by spaces. The first word is capitalized, and most other words are lowercase, except for proper nouns and acronyms. Punctuation characters are allowed.

|Example inputs |Example outputs |:-----------------------------------|:---------------------------------------------- |hello_world |Hello world |this is the shipengine api |This is the ShipEngine API

titleCase(text, [options])

Title case strings follow title case rules. Words are separated by spaces, most words are capitalized, and punctuation characters are allowed.

|Example inputs |Example outputs |:-----------------------------------|:---------------------------------------------- |hello_world |Hello World |this is the shipengine api |This is the ShipEngine API

Options object

All of the ShipEngine Capitalization function accept an optional second argument, which is an options object. This object can contain any of the following options:

|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.For example, snakeCase("4x6 label") would throw an error because snake case strings cannot start with a number. But snakeCase("4x6 label", { prefix: "size" }) would return size_4x6_label.Note: The prefix is only added when needed. So snakeCase("label size 4x6", { prefix: "size" }) would not use the prefix.