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-in-js

v1.0.1

Published

"functions to mutate strings in JavaScript"

Downloads

1

Readme

string-in-js npm package

The string-in-js npm package provides string manipulation functions designed to enhance JavaScript's built-in string capabilities. It provides a set of intuitive functions that allow you to easily transform and manipulate strings in various ways.

Installation

To start using string-in-js in your JavaScript projects, you can install it via npm:

npm install string-in-js

Usage

Once you have installed string-in-js, you can import the desired functions into your JavaScript code:

const stringJS = require('string-in-js');

OR

const {
    capitalizeString,
    titleizeString,
    camelizeString,
    underscoreString,
    dasherizeString,
    kebabizeString,
    humanizeString,
} = require('string-in-js');

Features

string-in-js offers a wide range of features that empower you to work with strings more effectively:

  • Capitalization: Convert the first character of a string to uppercase using the capitalizeString function.
  • Title Case: Transform a string by capitalizing the first character of each word with the titleizeString function.
  • Camel Case: Convert a string to camel case by removing underscores and capitalizing the following character using the camelizeString function.
  • Snake Case: Transform a string to snake case by inserting underscores between words and making it lowercase with the underscoreString function.
  • Kebab Case: Convert a string to kebab case by replacing underscores with dashes using the dasherizeString function.
  • Custom Kebabization: Apply custom kebabization rules by replacing non-alphabetic characters with dashes using the kebabizeString function.
  • Humanization: Convert an underscored or dasherized string to a human-readable form using the humanizeString function.

Functions and Examples

string-in-js provides the following functions for string manipulation:

capitalizeString(string)

Converts the first character of a string to uppercase.

Example:

const { capitalizeString } = require('string-in-js');

console.log(capitalizeString('hello')); // Output: Hello
console.log(capitalizeString('world')); // Output: World

titleizeString(string)

Converts the first character of each word in a string to uppercase.

Example:

const { titleizeString } = require('string-in-js');

console.log(titleizeString('hello world')); // Output: Hello World
console.log(titleizeString('the quick brown fox')); // Output: The Quick Brown Fox

camelizeString(string)

Converts a string to camel case by removing underscores and capitalizing the following character.

Example:

const { camelizeString } = require('string-in-js');

console.log(camelizeString('some_variable_name')); // Output: someVariableName
console.log(camelizeString('another_string')); // Output: anotherString

underscoreString(string)

Converts a string to snake case by inserting underscores between words and making it lowercase.

Example:

const { underscoreString } = require('string-in-js');

console.log(underscoreString('helloWorld')); // Output: hello_world
console.log(underscoreString('anotherExampleString')); // Output: another_example_string

dasherizeString(string)

Converts a string to kebab case by replacing underscores with dashes.

Example:

const { dasherizeString } = require('string-in-js');

console.log(dasherizeString('hello_world')); // Output: hello-world
console.log(dasherizeString('another_example_string')); // Output: another-example-string

kebabizeString(string)

Converts a string to kebab case by replacing non-alphabetic characters with dashes.

Example:

const { kebabizeString } = require('string-in-js');

console.log(kebabizeString('Hello World')); // Output: hello-world
console.log(kebabizeString('Some String, Here')); // Output: some-string--here

humanizeString(string)

Converts an underscored or dasherized string to a human-readable form.

Example:

const { humanizeString } = require('string-in-js');

console.log(humanizeString('hello_world')); // Output: Hello world
console.log(humanizeString('hel--/;[]][]#$#$lo #$#wo#$#rl#$#d')); // Output: Hel lo wo rl d

Contributing

I welcome contributions from the community to improve and expand the functionality of string-in-js. If you have any suggestions, bug reports, or feature requests, please don't hesitate to open an issue or submit a pull request on the GitHub repository.

  • The package is intended to be used for educational purposes only.