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

eg-string-modification

v1.0.4

Published

EG-string-modify is a collection of string modification utility functions for Node.js

Downloads

11

Readme

EG-string-modify

npm version

EG-string-modify is a collection of string modification utility functions for Node.js.

Link to npm package

https://www.npmjs.com/package/eg-string-modification

Installation

Install the package using npm:

npm install EG-string-modify

Import the package into your project:

const eg = require('eg-string-modify');

Functions

capitalize(string) Capitalizes the first letter of a given string.

const capitalized = eg.capitalize('hello');
console.log(capitalized); // Output: "Hello"

allCaps(string)

Converts the given string to uppercase.

const uppercase = eg.allCaps('hello');
console.log(uppercase); // Output: "HELLO"

capitalizeWords(string)

Capitalizes the first letter of each word in the given string.

const capitalizedWords = eg.capitalizeWords('hello world');
console.log(capitalizedWords); // Output: "Hello World"

capitalizeHeadline(string)

Capitalizes all words in a headline, except specified exception words, unless one of those words is the first word of the string.

const headline = eg.capitalizeHeadline('the greatest hello in the world');
console.log(headline); // Output: "The Greatest Hello in the World

removeExtraSpaces(string)

Removes extra spaces from the beginning and end of the given string, and replaces consecutive spaces with a single space.

const trimmed = eg.removeExtraSpaces('   hello   world   ');
console.log(trimmed); // Output: "hello world"

kebobCase(string)

Converts the given string to kebab case by removing special characters and replacing spaces with hyphens.

const kebabCased = eg.kebabCase('  I am hungry!');
console.log(kebabCased); // Output: "i-am-hungry"

snakeCase(string)

Converts the given string to snake case by removing special characters and replacing spaces with underscores.

const snakeCased = eg.snakeCase('  SSSS! I am a  snake');
console.log(snakeCased); // Output: "ssss_i_am_a_snake"

camelCase(string)

Converts the given string to camel case by removing special characters, capitalizing the first letter of each word (except the first), and removing spaces.

const camelCased = eg.camelCase('  camel sounds! i am a  camel');
console.log(camelCased); // Output: "camelSoundsIAmACamel"

shift(string)

Shifts the characters of the given string one position to the left, with the first character moving to the end.

const shifted = eg.shift('hello');
console.log(shifted); // Output: "elloh"

makeHashTag(string)

Creates an array of hashtags from the words in the given string.

const hashTags = eg.makeHashTag('Hello world javascript');
console.log(hashTags); // Output: ["#Hello", "#world", "#javascript"]

isEmpty(string)

Returns true if the given string is empty or contains only whitespace.

const emptyCheck1 = eg.isEmpty('Abc def');
console.log(emptyCheck1); // Output: false
const emptyCheck2 = eg.isEmpty(`   
			
			`);
console.log(emptyCheck2); // Output: true