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

stringloom

v1.1.0

Published

A lightweight collection of handy string manipulation utilities — slugify, truncate, capitalize, camelToKebab, maskEmail, and more.

Readme

npm version npm downloads license GitHub stars

stringloom

A lightweight, zero-dependency collection of string manipulation utilities for JavaScript and TypeScript. Think of it as a focused alternative to lodash's string methods.

Install

npm install stringloom

Usage

import { slugify, maskEmail, toCamelCase } from "stringloom";

slugify("Hello World!");           // "hello-world"
maskEmail("[email protected]"); // "j******[email protected]"
toCamelCase("background-color");   // "backgroundColor"

Works with both ESM (import) and CommonJS (require). Full TypeScript types included.

API

Slugify

slugify("Hello World!")                       // "hello-world"
slugify("Héllo Wörld")                        // "hello-world"
slugify("foo bar", { separator: "_" })        // "foo_bar"
slugify("Hello World", { lowercase: false })  // "Hello-World"

| Option | Type | Default | Description | |-------------|----------|---------|-------------------------------------| | separator | string | "-" | Character to replace spaces with | | lowercase | boolean| true | Convert to lowercase |

Truncate

truncate("The quick brown fox jumps over the lazy dog", { length: 20 })
// "The quick brown fox…"

truncate("abcdefghij", { length: 7, ellipsis: "...", wordBoundary: false })
// "abcd..."

| Option | Type | Default | Description | |----------------|----------|---------|--------------------------------------| | length | number | 30 | Max length including ellipsis | | ellipsis | string | "…" | String appended when truncated | | wordBoundary | boolean| true | Truncate at nearest word boundary |

Truncate (Middle)

truncateMiddle("abcdefghijklmnopqrstuvwxyz", { length: 10 })
// "abcde…wxyz"

| Option | Type | Default | Description | |------------|----------|---------|--------------------------------------| | length | number | 30 | Max length including ellipsis | | ellipsis | string | "…" | String inserted in the middle |

Capitalize

capitalize("hello world")       // "Hello world"
capitalizeWords("hello world")  // "Hello World"

Case Conversion

toCamelCase("hello-world")       // "helloWorld"
toPascalCase("hello-world")      // "HelloWorld"
toKebabCase("helloWorld")        // "hello-world"
toSnakeCase("helloWorld")        // "hello_world"
camelToKebab("backgroundColor")  // "background-color"
camelToSnake("backgroundColor")  // "background_color"

Handles camelCase, PascalCase, kebab-case, snake_case, and whitespace-separated input.

Masking

maskEmail("[email protected]")  // "j******[email protected]"

mask("4242424242424242")                           // "4242************"
mask("4242424242424242", { keepStart: 0, keepEnd: 4 }) // "************4242"

maskPhone("+1 (555) 123-4567")  // "***********4567"

| Option (mask) | Type | Default | Description | |----------------|----------|---------|--------------------------------------| | char | string | "*" | Character used for masking | | keepStart | number | 4 | Visible characters at the start | | keepEnd | number | 0 | Visible characters at the end |

Reverse

reverse("hello")  // "olleh"
reverse("🚀🌍")   // "🌍🚀"

Unicode-safe string reversal.

Counting

countWords("Hello, World!")    // 2
countOccurrences("banana", "an")  // 2

Padding

padStart("42", 5, "0")  // "00042"
padEnd("42", 5, "0")    // "42000"

Template

template("Hello, {{name}}!", { name: "World" })  // "Hello, World!"
template("{{a}} + {{b}} = {{c}}", { a: "1", b: "2", c: "3" })
// "1 + 2 = 3"

Simple {{key}} placeholder interpolation. Unknown placeholders are left as-is.

Strip / Collapse

stripHtml("<p>Hello <b>World</b></p>")  // "Hello World"
stripWhitespace("  h e l l o  ")        // "hello"
collapseWhitespace("  hello   world  ") // "hello world"

Deburr (Remove Accents)

deburr("Héllo Wörld") // "Hello World"

Escape RegExp

escapeRegExp("hello.*(world)?") // "hello\\.\\*\\(world\\)\\?"

Checks

isPalindrome("Racecar")   // true
isBlank("  ")              // true
isNumeric("12345")         // true
isAlpha("hello")           // true
isAlphanumeric("hello123") // true

Validators

isEmail("[email protected]")           // true
isEmail("not-an-email")      // false
isUrl("https://example.com") // true
isUrl("example.com")         // false

Sanitize Filename

sanitizeFilename("my<file>:name?.txt") // "my_file_name_.txt"
sanitizeFilename("CON")                // "_CON"

Initials

initials("John Doe")           // "JD"
initials("alice bob charlie")  // "ABC"

Excerpt

excerpt("The quick brown fox jumps over the lazy dog", "fox", { radius: 5 })
// "…brown fox jumps…"

| Option | Type | Default | Description | |------------|----------|---------|----------------------------------------| | radius | number | 30 | Characters to include around the phrase| | omission | string | "…" | Indicator for omitted text |

All Exports

| Function | Description | |----------------------|--------------------------------------------------| | slugify | Convert string to URL-friendly slug | | deburr | Remove accents/diacritics | | truncate | Truncate with ellipsis & word boundary support | | truncateMiddle | Truncate from the middle | | capitalize | Capitalize first letter | | capitalizeWords | Capitalize first letter of every word | | toCamelCase | Convert to camelCase | | toPascalCase | Convert to PascalCase | | toKebabCase | Convert to kebab-case | | toSnakeCase | Convert to snake_case | | camelToKebab | camelCase/PascalCase to kebab-case | | camelToSnake | camelCase/PascalCase to snake_case | | maskEmail | Mask an email address | | mask | Mask a string with configurable visibility | | maskPhone | Mask a phone number (keeps last 4 digits) | | reverse | Unicode-safe string reversal | | countWords | Count words in a string | | countOccurrences | Count substring occurrences | | padStart | Left-pad a string | | padEnd | Right-pad a string | | template | {{key}} placeholder interpolation | | stripHtml | Remove HTML tags | | stripWhitespace | Remove all whitespace | | collapseWhitespace | Collapse whitespace to single spaces | | escapeRegExp | Escape a string for safe regex usage | | isPalindrome | Check if string is a palindrome | | isBlank | Check if string is empty/whitespace | | isNumeric | Check if string is all digits | | isAlpha | Check if string is all letters | | isAlphanumeric | Check if string is letters + digits | | isEmail | Basic email validation | | isUrl | Check if string is a valid http/https URL | | sanitizeFilename | Sanitize a string for safe filenames | | initials | Extract initials from a name | | excerpt | Extract snippet around a search phrase |

License

MIT