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

case-utils

v2.0.5

Published

Utility tools for working with case changes.

Downloads

4

Readme

case-utils

Utility functions for working with string case in Node.js.

See docs/types_of_cases.md for examples and more documentation.

Also see the contents of the migration folder for what might happen in the future.

Motivation

Understanding transformations and the code that does them

The advantage of using this package is that there are a few dependencies and string manipulation code can be seen in a single file (index.js).

Understanding what the transformations do is necessary and not just helpful.

Transformations should be documented.

At first, you might think you know what transformations are doing, but consider this:

  • Do you remember the names of the cases you are converting from and to?

  • Do you remember the difference between 'dashes' and 'hyphens'?

  • What happens to all and each of the characters after the transformation? In 9 July 2020, the toStart() function in this package converted 'this is a test' to 'This Is A Test', but it also converted 'this is a tEST' to 'This Is A Test'. This meant that, not only was the first character of each word transformed, the others were too ("EST" to "est").

9 July 2020 Log: The toStart() function name and functionality will probably change.

Transformation function names

This is not started or complete yet.

Indicates what you are converting from and what you are converting to in the same function name.

A more formal resource

Get all of this done formally, because it's getting annoying even when I am writing in C#. See docs/types_of_cases.md.

Installation

npm i case-utils --save

Usage

The names of these functions will most likely change in the future. For now, they kind of work.

camelToKebab()

Converts 'thisIsATest' to 'this-is-a-test'.

Currently also does this for Pascal case.

CaseUtils.camelToKebab(string) accepts a string as an argument and returns a string.

Example:

const CaseUtils = require('case-utils');

console.log(CaseUtils.camelToKebab('thisIsATest')); // Returns `this-is-a-test`.

removeHyphens()

Converts 'this-is-a-test' to 'this is a test'.

CaseUtils.removeHyphens(string) accepts a string as an argument and returns a string.

Example:

const CaseUtils = require('case-utils');

console.log(CaseUtils.removeHyphens('this-is-a-test')); // Returns `this is a test`.

toStart()

Converts 'this is a test' to 'This Is A Test'.

Also: 'this is a tEST' to 'This Is A Test'.

CaseUtils.toStart(string) accepts a string as an argument and returns a string.

Example:

const CaseUtils = require('case-utils');

console.log(CaseUtils.toStart('this is a test')); // Returns `This Is A Test`.