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

string-therapy

v2.2.2

Published

A small but convinient tool to convert your strings to a more code friendly format and back. Useful for dynamic content and helpful for maintaining consistency between your keys, variables and id's.

Downloads

8

Readme

String Therapy

Yeah, the name is a play on "string theory" but the goal of this package is to provide some support to convert our strings we use in our code to a more friendly form that plays nice when used as keys and ID's.

The Rundown

If you been developing for any amount of time, you'll understand that strings come from all directions. Be it from a user when they submit a form, parsing a document or simply sorting files. In many cases we might want to use these strings as an ID or key and thats where "String Therapy" comes in. This package has got the common case formatting that we tend to use plus a feature to revert the string to an "english" format, either way I hope you find it useful to some degree.

Usage

Install it into your app first, of course!

npm i string-therapy

Next up, just add it into your project and use away!

//-- slap this package into your project
const st = require("string-therapy");
//-or-//
import st from "string-therapy";
//-Import type for Typescript Use-//
import { StringTherapy } from "string-therapy/lib/StringTherapy"; //- Typescript Use
let newString:StringTherapy = st("Your New String");

//-- initiate it with your string
let newString = st("Your New string");

//-- call a method to tame that fella
newString.toCamelCase; //- outputs: yourNewString
/* Other methods defined below */

The Deets

toCamelCase

Converts your string to Camel Case format, possibly the most common format in Javascript.

const st = require("string-therapy");
let newString = st("Some String");
newString.toCamelCase; //- Outputs: someString

toPascalCase

Converts your string to Pascal Case format, used often for class naming and templates.

const st = require("string-therapy");
let newString = st("Some String");
newString.toPascalCase; //- Outputs: SomeString

toKebabCase

Converts your string to Kebab Case format, used often in CSS.

const st = require("string-therapy");
let newString = st("Some String");
newString.toKebabCase; //- Outputs: some-string

toSnakeCase

Converts your string to Snake Case format, often found for ID's and DB related keys.

const st = require("string-therapy");
let newString = st("Some String");
newString.toCamelCase; //- Outputs: some_string

toEnglish

Not actually english but you get the gist, it's supposed to convert your already code friendly strings to "english" format with spaces and all.

const st = require("string-therapy");
let newString = st("camelCaseString");
newString.toEnglish; //- Outputs: Camel case string

Log

  • 2.2.2 - Code Cleanup; Optimizing for Typescript
  • 2.2.1 - Updated Readme
  • 2.2.0 - Code cleanup and restructure
  • 2.1.1 - Corrected "type" import
  • 2.1.0 - Corrected "import"
  • 2.0.0 - Using "getter" methods to help make things simpler
  • 1.0.0 - Support for digits at end of string and corrected issue detecting an underscore (_) in conversions
  • 0.1.0 - Declaration file for "import" support
  • 0.0.2 - README added
  • 0.0.1 - First Publish