A strongly-typed TypeScript utility library providing pure, well-tested functions across 8 domains: array, asserts, boolean, enum, function, lru-cache, object, string, and time. Targets Node.js 22+ as an ESM-only package with full TypeScript type declarations and 80%+ code coverage across all utilities.
- Node.js: >= 22.x
- TypeScript: >= 5.x
- Module System: ESM (ECMAScript modules)
npm install @pawells/typescript-commonyarn add @pawells/typescript-commonimport { chunk, uniq, partition } from '@pawells/typescript-common/array';
const numbers = [1, 2, 2, 3, 4, 5];
const unique = uniq(numbers); // [1, 2, 3, 4, 5]
const chunked = chunk([1, 2, 3, 4, 5], 2); // [[1, 2], [3, 4], [5]]
const [even, odd] = partition([1, 2, 3, 4, 5], n => n % 2 === 0);
// even: [2, 4], odd: [1, 3, 5]import { pick, omit, merge } from '@pawells/typescript-common/object';
const user = { id: 1, name: 'Alice', email: 'alice@example.com', password: 'secret' };
const public_data = omit(user, ['password']); // { id: 1, name: 'Alice', email: '...' }
const selected = pick(user, ['name', 'email']);
// { name: 'Alice', email: 'alice@example.com' }
const merged = merge({ a: 1 }, { b: 2 }); // { a: 1, b: 2 }import { capitalize, camelCase, isEmail } from '@pawells/typescript-common/string';
const str = 'hello world';
const capitalized = capitalize(str); // 'Hello world'
const camel = camelCase('hello-world-string'); // 'helloWorldString'
const valid = isEmail('user@example.com'); // trueimport { assert, isDefined } from '@pawells/typescript-common/asserts';
const value: unknown = getSomeValue();
assert(isDefined(value), 'value must be defined');
// TypeScript now narrows value to exclude undefined
const result = isDefined(value) ? value.toUpperCase() : 'N/A';| Domain | Description |
|---|---|
| array | Array manipulation utilities (chunk, uniq, partition, flatten, etc.) |
| asserts | Runtime type assertions and guards with TypeScript narrowing support |
| boolean | Boolean utilities and logical operation helpers |
| enum | Enum utilities for validation, iteration, and type-safe enum operations |
| function | Function utilities (compose, pipe, memoize, debounce, throttle, etc.) |
| lru-cache | Memory-efficient LRU cache implementation for expensive computations |
| object | Object manipulation (pick, omit, merge, entries, values, keys with types) |
| string | String utilities (capitalize, camelCase, slugify, isEmail, etc.) |
| time | Time and duration utilities (ms conversion, formatting, parsing) |
For detailed API documentation, source code, and examples, see the package documentation.
MIT — See LICENSE for details.