Package Exports
- @n1hal/strx
- @n1hal/strx/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@n1hal/strx) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
@n1hal/strx
Repository for NPM package @n1hal/strx, utility package for string manipulations and string related tools. Small, dependency-free string helpers โ clean, consistent, and zero bloat.
๐ Features
- ๐ก Lightweight โ No dependencies, <1 KB minified.
- โจ Modern ESM โ Works seamlessly in Node and browsers.
- ๐ Typed โ Includes full TypeScript definitions.
- โก Handy โ Covers common string formatting and casing tasks.
๐ฆ Installation
npm i @n1hal/strxOr with pnpm:
pnpm add @n1hal/strxOr with Yarn:
yarn add @n1hal/strx๐ง Usage
import { capitalize, slugify, camelCase } from "@n1hal/strx";
capitalize("hello world"); // โ "Hello world"
camelCase("hello world"); // โ "helloWorld"
slugify("Hello World! Cafรฉ"); // โ "hello-world-cafe"Or use the default export:
import strx from "@n1hal/strx";
strx.titleCase("once upon a time"); // โ "Once Upon A Time"
strx.truncate("A very long text that should be shortened", 20);
// โ "A very long text..."โ๏ธ TypeScript Support
All functions are typed automatically:
import { titleCase } from "@n1hal/strx";
const title: string = titleCase("make it nice");๐งช Example Playground
You can quickly test all functions in Node REPL:
node
> import * as strx from "@n1hal/strx";
> strx.camelCase("Hello there friend");
'helloThereFriend'๐ License
๐ Contribute
If youโd like to suggest new helpers or improve code coverage:
- Fork the repo
- Add your function to
index.js - Export and update
index.d.ts - Open a PR โจ
Keep your strings sharp with @n1hal/strx โ๏ธ