DEV Community

Cover image for strz – Very Strongly Typed String Functions
Michael
Michael

Posted on

strz – Very Strongly Typed String Functions

GitHub logo dilan-dio4 / strz

💪 Very strongly typed string functions in TypeScript

strzVery Strongly Typed String Functions

  • 0️⃣ No dependencies
  • 🌲 Tree shakable
  • 📦 Small
  • 5️⃣ Typescript 5
  • 📝 Strongly typed

Why?

In projects that encourage strong typing, the standard library requires manually casting to match function parameter signatures. strz brings the power of strong typing to the standard library.

Example

import { split, suffix } from 'strz'
const str = "The quick brown fox jumps over the lazy dog"

const splitStr = split(str, " ") // splitStr is of type ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog"]
const suffixed = suffix(str, "!") // suffixed is of type "The quick brown fox jumps over the lazy dog!"
Enter fullscreen mode Exit fullscreen mode

Installation

npm install strz
Enter fullscreen mode Exit fullscreen mode

Usage

import {
  charAt,
  toLowerCase,
  toUpperCase,
  toArray,
  slice,
  uncapitalize,
  capitalize,
  prefix,
  suffix,
  split,
  trim,
  trimStart,
  trimEnd
Enter fullscreen mode Exit fullscreen mode

Top comments (0)