A personal utility toolkit - reusable TypeScript functions, helpers, and patterns
npm install @d3oxy/utilsA personal utility toolkit — a growing collection of reusable TypeScript functions, helpers, and patterns that simplify development across multiple projects.
- Write once, reuse everywhere — consistent logic across projects
- Clean, typed, and minimal — no bloated dependencies
- Composable — each utility can be used independently
``bash`
npm install @d3oxy/utilsor
pnpm add @d3oxy/utilsor
yarn add @d3oxy/utils
Each utility is imported directly from its file path:
`typescript`
import { generateUniqueSlug } from "@d3oxy/utils/slug/generate-unique-slug";
import { asyncMap } from "@d3oxy/utils/array/async-map";
import { pick } from "@d3oxy/utils/object/pick";
Adding new utilities: Simply create a new .ts file in src/ and it will automatically be available as an import path. For example:
- src/date/format-date.ts → @d3oxy/utils/date/format-datesrc/validation/is-email.ts
- → @d3oxy/utils/validation/is-email
No configuration needed! The package exports are set up to automatically expose all files.
Utilities for working with arrays and iterables.
- asyncMap — Apply async functions over iterables (including promises)
- pruneNull — Filter out null elements from arrays
Utilities for runtime assertions and type guards.
- assert — Validate truthiness at runtime with type guards
- nullThrows — Throw if value is null, with type refinement
Utilities for manipulating and transforming objects.
- pick — Select specific keys from objects
- omit — Exclude keys from objects
Utilities for generating URL-safe slugs.
- generateUniqueSlug — Generate unique URL-safe slugs with collision handling
TypeScript type helpers and utilities for advanced type manipulation.
- BetterOmit — Enhanced Omit type that preserves index signaturesExpand
- — Simplify TypeScript's object type renderingEquals
- — Test if two types are exactly the sameEmptyObject
- — Empty object type definitionErrorMessage
- — Type-level error message utility
`bashInstall dependencies
pnpm install
Project Structure
`
@d3oxy/utils/
├── src/
│ ├── array/
│ │ ├── async-map.ts
│ │ └── prune-null.ts
│ ├── assert/
│ │ ├── assert.ts
│ │ └── null-throws.ts
│ ├── object/
│ │ ├── omit.ts
│ │ └── pick.ts
│ ├── slug/
│ │ └── generate-unique-slug.ts
│ └── type/
│ ├── better-omit.ts
│ ├── empty-object.ts
│ ├── equals.ts
│ ├── error-message.ts
│ └── expand.ts
├── docs/
│ ├── array.md
│ ├── assert.md
│ ├── object.md
│ ├── slug.md
│ └── type.md
├── tests/
│ └── slug/
│ └── generate-unique-slug.test.ts
├── dist/ # Built output (gitignored)
├── package.json
├── tsconfig.json
├── tsup.config.ts
└── biome.json
`Credits & Thanks
This utility library includes code and inspiration from various open-source projects and communities:
- Convex — Several utilities (
asyncMap, pruneNull, pick, omit, nullThrows, BetterOmit, Expand, EmptyObject, ErrorMessage) were adapted from Convex's internal utilities. Thank you to the Convex team for their excellent work and for making these patterns available.- TypeScript Community — The
Equals` type utility is based on a solution from the TypeScript GitHub issue tracker (#27024) by the TypeScript community.- Open Source Community — Thanks to all the developers who share their knowledge and code, making projects like this possible.
All utilities have been adapted, refactored, and documented to fit this library's conventions and to remove framework-specific dependencies.
The following categories are planned for future releases:
- Dates & Time – formatters, relative-time helpers
- Validation & Guards – type-safe and reusable logic
- API Helpers – error wrappers, pagination, retry logic
- Misc Utils – random generators, async helpers
This is a personal utility library, but suggestions and improvements are welcome!
MIT © d3oxy