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

strong-string

v1.0.0

Published

Strongly typed string methods

Downloads

9

Readme

strong-string

Overview

strong-string is a TypeScript utility package that provides strongly typed string manipulation functions. Unlike native String.prototype methods or traditional utility libraries, strong-string offers compile-time type safety, ensuring that string transformations like camelCase, snakeCase, toUpperCase, and others are fully type-checked by TypeScript.

By leveraging TypeScript’s type inference, strong-string allows you to perform string manipulations with complete confidence, ensuring that both runtime behavior and types remain predictable and safe.

Features

  • Compile-time type safety for string manipulations.
  • Fully typed transformations, ensuring TypeScript infers the result correctly.
  • No external setup—ready to use out of the box.
  • Simple, lightweight, and designed to integrate seamlessly with TypeScript projects.

Installation

To install the package, use npm, yarn, pnpm, or bun:

npm install strong-string

or

yarn add strong-string

or

pnpm add strong-string

or

bun add strong-string

Usage

You can import and use any of the available functions with full TypeScript type inference.

import {
  toCamelCase,
  toSnakeCase,
  toUpperCase,
  toKebabCase,
  toScreamingSnakeCase,
  toCapitalize,
  toDelimiterCase,
  split,
  join,
} from 'strong-string';

const myString = 'hello world';

// Strongly typed string transformations
const camelCased = toCamelCase(myString); // "helloWorld" - TypeScript infers CamelCase<'hello world'>
const snakeCased = toSnakeCase(myString); // "hello_world" - Inferred as SnakeCase<'hello world'>
const upperCased = toUpperCase(myString); // "HELLO WORLD" - Result as Uppercase<'hello world'>
const kebabCased = toKebabCase(myString); // "hello-world" - Inferred as KebabCase<'hello world'>
const screamingSnakeCased = toScreamingSnakeCase(myString); // "HELLO_WORLD" as ScreamingSnakeCase<'hello world'>
const capitalized = toCapitalize(myString); // "Hello world" - Capitalize<'hello world'>

// Delimited transformations
const delimiterCased = toDelimiterCase(myString, '-'); // "hello-world" - DelimiterCase<'hello world', '-'>

// Split and Join with strong types
const splitString = split(myString, ' '); // ["hello", "world"] as Split<'hello world', ' '>
const joinedString = join(['hello', 'world'], '-'); // "hello-world" as Join<['hello', 'world'], '-'>

Available Functions

toUpperCase

Converts a string to uppercase with compile-time TypeScript guarantees.

const result = toUpperCase('hello world'); // "HELLO WORLD" as Uppercase<'hello world'>

toLowercase

Converts a string to lowercase with compile-time type inference.

const result = toLowercase('HELLO WORLD'); // "hello world" as Lowercase<'HELLO WORLD'>

toCapitalize

Capitalizes the first letter of the string, with TypeScript inferring the result as Capitalize<string>.

const result = toCapitalize('hello world'); // "Hello world" as Capitalize<'hello world'>

toCamelCase

Converts a string to camelCase with full compile-time type inference.

const result = toCamelCase('hello world'); // "helloWorld" as CamelCase<'hello world'>

toSnakeCase

Converts a string to snake_case, ensuring TypeScript correctly infers the result.

const result = toSnakeCase('hello world'); // "hello_world" as SnakeCase<'hello world'>

toKebabCase

Converts a string to kebab-case with compile-time guarantees.

const result = toKebabCase('hello world'); // "hello-world" as KebabCase<'hello world'>

toScreamingSnakeCase

Converts a string to SCREAMING_SNAKE_CASE, fully typed at compile-time.

const result = toScreamingSnakeCase('hello world'); // "HELLO_WORLD" as ScreamingSnakeCase<'hello world'>

toDelimiterCase

Converts a string to a delimited case, using a specified delimiter, with full compile-time safety.

const result = toDelimiterCase('hello world', '-'); // "hello-world" as DelimiterCase<'hello world', '-'>

split

Splits a string by a specified delimiter, ensuring type inference and compile-time safety.

const result = split('hello-world', '-'); // ["hello", "world"] as Split<'hello-world', '-'>

join

Joins an array of strings into a single string with a given delimiter, preserving type safety.

const result = join(['hello', 'world'], '-'); // "hello-world" as Join<['hello', 'world'], '-'>

Type Safety and Compile-Time Guarantees

Unlike String.prototype methods or typical utility libraries, strong-string provides both runtime string manipulation and compile-time guarantees through TypeScript. With strong typing, strong-string ensures that transformations are interpreted at compile-time, allowing TypeScript to infer the result types accurately.

License

This project is licensed under the MIT License.

Contributing

Contributions are welcome! If you find an issue or have a feature request, feel free to submit a pull request or file an issue on the GitHub repository.