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 🙏

© 2026 – Pkg Stats / Ryan Hefner

transform-case

v1.1.0

Published

Transforms casing and spacing of a string

Readme

CircleCI Coverage Status

TransformCase

Here is the case and separation transformer that transliterates diacriticals and ligatures when your texts are in any Latin script.

Install

Install the package as npm package. Provided are a umd-formatted file in the dist folder to require or just read and an es-module in the module folder to import.

Usage

A human text can be transformed to a systematic phrase like this:

transformCase('A sentence, text for humans.').camelCase()

These will render:

const textIntake = transformCase('A sentence, text for humans.')

textIntake.camelCase()   // ==> 'aSentenceTextForHumans'
textIntake.pascalCase()  // ==> 'ASentenceTextForHumans'
textIntake.dotCase()     // ==> 'a.sentence.text.for.humans'
textIntake.paramCase()   // ==> 'a-sentence-text-for-humans'
textIntake.pathCase()    // ==> 'a/sentence/text/for/humans'
textIntake.searchCase()   // ==> 'a+sentence+text+for+humans'
textIntake.snakeCase()   // ==> 'a_sentence_text_for_humans'
textIntake.spaceCase()   // ==> 'a sentence text for humans'
textIntake.constantCase()// ==> 'THIS_SENTENCE_TEXT_FOR_HUMANS'
textIntake.headerCase()  // ==> 'This-Sentence-Text-For-Humans'

A systematic text can be transformed to a human phrase like this:

const textIntake = transformCase('camelCasedInput')
textIntake.humanSentence()  // ==> 'Camel cased input'

const textIntake2 = transformCase(
    'snake_cased_input', {delimitInput: '_'}
)
textIntake2.humanTitle()     // ==> 'Snake Cased Input'

With a second argument, an options object can be passed:

{
    delimit: [word-or-regex1, word-or-regex2, ...],
    preserve: [word-or-regex1, word-or-regex2, ...],
}
delimit: {Array}
    keeps a letter-combination or a regular expression match
    as a delimited word,
    the word will be processed according to the pattern
preserve: {Array}
    keeps a letter-combination or a regular expression match
    as a delimited word and protects the case

Options for pure alphanumeric input

delimitLetterNumber: {Boolean}
    delimit when a letter is followed by a number (default: true)
delimitLowerUpper: {Boolean}
    delimit when a lowercase is followed by a uppercase (default: true)
delimitNumberLetter: {Boolean}
    delimit when a number is followed by a letter (default: true)
delimitUpperLower: {Boolean}
    delimit when a uppercase is followed by a lowercase (default: false)
delimitUpperUpperLower: {Boolean}
    delimit when a uppercase is followed by a uppercase plus lowercase (default: true)

Demo

.../transform-case/demo/demo.html
.../transform-case/demo/play.html

Transformation process

This module has two steps, an intake and a render step.

The intake step deduplicates whitespace in a space character, removes control characters, finds a delimiter, isolates delimit and preserve options and ends with an array of words.

We then have an object with collected data and a number of transform patterns to choose from.

{
    _orgin {
        input (string),
        isAlphaNumeric (boolean),
        normalised (string),
        revised (string)
    }
    options {
        (see above)
    }
    _phrase (delimited string),
    words (string[]),
    ...the transformation functions
}

The render step is merely choosing a pattern to apply to the array of words. There are three groups of similar patterns:

  • Cap-marked words (camelCase, pascalCase)
  • Human, linguistic (humanSentence, humanTitle)
  • Delimited lowercase (dotCase, paramCase, etcetera)

Apart from the human group, in all patterns punctuation is stripped, diacritics are stripped, ligatures are decomposed