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 🙏

© 2026 – Pkg Stats / Ryan Hefner

string-utils-lib

v1.1.0

Published

A comprehensive string manipulation utility library

Readme

String Utils Library

A comprehensive JavaScript utility library for string manipulation, providing a wide range of functions for text transformation, analysis, and generation.

Installation

npm i string-utils-lib

You can also find the package on npm: string-utils-lib

GitHub Repository: js-string-lib

Quick Start

Basic Usage

// Import the functions you need
import { capitalize, camelCase, snakeCase } from 'string-utils-lib';

// Use the functions
const text = 'hello world';
console.log(capitalize(text));    // Output: 'Hello world'
console.log(camelCase(text));     // Output: 'helloWorld'
console.log(snakeCase(text));     // Output: 'hello_world'

Running in Node.js

  1. Create a new file (e.g., example.js)
  2. Add your code:
const { capitalize, camelCase } = require('string-utils-lib');

const result = capitalize('hello world');
console.log(result); // Output: 'Hello world'
  1. Run the file:
node example.js

Running in Browser

  1. Include the library in your HTML:
<script src="node_modules/string-utils-lib/dist/index.js"></script>
  1. Use the functions:
const result = stringUtils.capitalize('hello world');
console.log(result); // Output: 'Hello world'

Running in TypeScript

import { capitalize, camelCase } from 'string-utils-lib';

const text: string = 'hello world';
const result: string = capitalize(text);
console.log(result); // Output: 'Hello world'

Development

Prerequisites

  • Node.js (v14 or higher)
  • npm (v6 or higher)

Setup

  1. Clone the repository:
git clone https://github.com/Joshkaki00/js-string-lib.git
cd js-string-lib
  1. Install dependencies:
npm install

Running Tests

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

Building

# Build the library
npm run build

# Build in watch mode
npm run build:watch

Linting

# Run linter
npm run lint

# Fix linting issues
npm run lint:fix

Features

  • TypeScript Support: Full TypeScript definitions for better developer experience
  • Case Manipulation: Convert between different text cases (camelCase, snake_case, etc.)
  • Text Transformation: Truncate, reverse, strip HTML, etc.
  • Text Analysis: Count words, check for emails or URLs, etc.
  • String Generation: Generate random strings, pluralize text, mask characters

Case Manipulation

  • capitalize(str): Capitalizes the first letter of a string
  • camelCase(str): Converts string to camelCase
  • pascalCase(str): Converts string to PascalCase
  • snakeCase(str): Converts string to snake_case
  • kebabCase(str): Converts string to kebab-case
  • titleCase(str): Converts string to Title Case

Text Transformation

  • truncate(str, length, suffix): Truncates text to specified length with optional suffix
  • ellipsis(str, length): Truncates text with ellipsis if it exceeds length
  • reverse(str): Reverses a string
  • slugify(str): Converts string to URL-friendly slug
  • stripHTML(str): Removes HTML tags from string
  • stripPunctuation(str): Removes all punctuation from string

Text Analysis

  • countWords(str): Counts words in a string
  • countOccurrences(str, substr): Counts occurrences of a substring
  • isEmail(str): Validates email addresses
  • isURL(str): Validates URLs
  • containsSubstring(str, substr, caseSensitive): Checks for substring presence
  • hasEmoji(str): Detects emoji presence in string

String Generation

  • randomString(length, options): Generates random strings with customizable options
  • pluralize(singular, plural, count): Returns singular or plural form based on count
  • maskString(str, visibleChars, options): Masks string with customizable options

Usage

// ES Module import
import { camelCase, truncate } from 'string-utils-lib';

// CommonJS require
const { camelCase, truncate } = require('string-utils-lib');

// TypeScript
import { camelCase, truncate, RandomStringOptions } from 'string-utils-lib';

camelCase('hello world'); // 'helloWorld'
truncate('hello world', 5); // 'hello'

Examples

Case Manipulation

import { pascalCase, snakeCase, titleCase } from 'string-utils-lib';

pascalCase('hello world'); // 'HelloWorld'
snakeCase('helloWorld'); // 'hello_world'
titleCase('hello world'); // 'Hello World'

Text Transformation

import { truncate, slugify, stripHTML } from 'string-utils-lib';

truncate('Hello world', 5, '...'); // 'Hello...'
slugify('Hello World!'); // 'hello-world'
stripHTML('<p>Hello <b>world</b></p>'); // 'Hello world'

String Generation

import { randomString, maskString } from 'string-utils-lib';

// Generate random string
randomString(8, { uppercase: true, numbers: true }); // 'aB3cD4eF'

// Mask string
maskString('1234567890', 4); // '1234******'
maskString('1234567890', 4, { showFirst: false }); // '******7890'

API Documentation

Each function is thoroughly documented with JSDoc comments, including:

  • Parameter descriptions
  • Return value descriptions
  • Usage examples
  • Edge case handling

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - feel free to use this library in your projects.