Skip to content

Latest commit

Β 

History

History
32 lines (22 loc) Β· 861 Bytes

File metadata and controls

32 lines (22 loc) Β· 861 Bytes

ts-utils

A lightweight collection of TypeScript utility functions for everyday development.

Features

  • πŸ”§ String utilities β€” slugify, truncate, capitalize, camelCase
  • πŸ“… Date helpers β€” relative time, format, timezone-aware parsing
  • πŸ”’ Number utils β€” clamp, round to precision, currency formatting
  • 🎯 Type guards β€” runtime type checking with TypeScript inference
  • ⚑ Zero dependencies β€” tree-shakeable ESM

Installation

npm install @lawrencekwan/ts-utils

Usage

import { slugify, relativeTime, clamp, isNonNullable } from '@lawrencekwan/ts-utils';

slugify('Hello World!');        // 'hello-world'
relativeTime(new Date('2024-01-01')); // '1 year ago'
clamp(150, 0, 100);            // 100
isNonNullable(value);          // type narrows to NonNullable<T>

License

MIT