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

easy-string-utils

v1.0.3

Published

One Stop for all string utility functions

Downloads

4

Readme

easy-string-utils

A comprehensive library of string utility functions for JavaScript/TypeScript.

Installation

You can install "easy-string-utils" via npm:

npm install easy-string-utils

Usage of various functions:

import { 
  reverseString,
  capitalizeString,
  toTitleCase,
  wordWrap,
  truncateString,
  generateRandomString,
  toCamelCase,
  toSnakeCase,
  toPascalCase,
  extractURLs,
  textToMorseCode,
  morseCodeToText,
  stripHTMLTags,
  countWords,
  generatePassword,
  formatPhoneNumber
} from 'easy-string-utils';

// Example usage for each function

// Reverse a string
console.log(reverseString("hello")); // Output: "olleh"

// Capitalize the first letter of a string
console.log(capitalizeString("hello world")); // Output: "Hello world"

// Convert a string to title case even the above function does its purpose i added as it is easily readable
console.log(toTitleCase("hello world")); // Output: "Hello World"

// Wrap text to a specified maximum line length
console.log(wordWrap("Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 20));
// Output:
// "Lorem ipsum dolor\nsit amet, consectetur\nadipiscing elit."

// Truncate a string to a specified maximum length
console.log(truncateString("Lorem ipsum dolor sit amet", 10)); // Output: "Lorem ipsu..."

// Generate a random string of a specified length
console.log(generateRandomString(8)); // Output: e.g., "oRb2Yv7A"

// Convert a string to Camel Case
console.log(toCamelCase("hello_world")); // Output: "helloWorld"

// Convert a string to Snake Case
console.log(toSnakeCase("helloWorld")); // Output: "hello_world"

// Convert a string to Pascal Case
console.log(toPascalCase("hello-world")); // Output: "HelloWorld"

// Extract URLs from a string
console.log(extractURLs("Visit our website at https://example.com for more information."));
// Output: ["https://example.com"]

// Convert text to Morse Code
console.log(textToMorseCode("hello")); // Output: ".... . .-.. .-.. ---"

// Convert Morse Code to text
console.log(morseCodeToText(".... . .-.. .-.. ---")); // Output: "hello"

// Strip HTML tags from a string
console.log(stripHTMLTags("<p>Hello, <b>world</b></p>")); // Output: "Hello, world"

// Count words in a string
console.log(countWords("Hello world")); // Output: 2

// Generate a random password
console.log(generatePassword(10)); // Output: e.g., "xY2!zB#8qR"

// Format a phone number based on the country code , you can pass country code in the first argument and second argument a phone number. 
console.log(formatPhoneNumber('+1', '1234567890')); // Output: "(123) 456-7890"