@d3oxy/utils
v0.2.0
Published
A personal utility toolkit - reusable TypeScript functions, helpers, and patterns
Maintainers
Readme
@d3oxy/utils
A personal utility toolkit — a growing collection of reusable TypeScript functions, helpers, and patterns that simplify development across multiple projects.
Philosophy
- Write once, reuse everywhere — consistent logic across projects
- Clean, typed, and minimal — no bloated dependencies
- Composable — each utility can be used independently
Installation
npm install @d3oxy/utils
# or
pnpm add @d3oxy/utils
# or
yarn add @d3oxy/utilsImport Structure
Each utility is imported directly from its file path:
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
Array Utilities
Utilities for working with arrays and iterables.
asyncMap— Apply async functions over iterables (including promises)pruneNull— Filter out null elements from arrays
Assertion Utilities
Utilities for runtime assertions and type guards.
assert— Validate truthiness at runtime with type guardsnullThrows— Throw if value is null, with type refinement
Object Utilities
Utilities for manipulating and transforming objects.
Slug Utilities
Utilities for generating URL-safe slugs.
generateUniqueSlug— Generate unique URL-safe slugs with collision handling
Type Utilities
TypeScript type helpers and utilities for advanced type manipulation.
BetterOmit— EnhancedOmittype 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
Development
# Install dependencies
pnpm install
# Build the library
pnpm build
# Run tests
pnpm test
# Run tests in watch mode
pnpm test --watch
# Type check
pnpm typecheck
# Lint code
pnpm lint
# Format code
pnpm format
# Run all checks (lint + format)
pnpm checkProject 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.jsonCredits & 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
Equalstype 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.
Upcoming Utilities
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
Contributing
This is a personal utility library, but suggestions and improvements are welcome!
License
MIT © d3oxy
