@batoanng/utils
General-purpose helpers and React hooks for the shared front-end ecosystem.
Quick install
npm install @batoanng/utilsPull utility functions and hooks from the package root
The package is tree-shakable, so consumers can import narrow helpers without paying for the full surface area.
Context
What It Covers
Reach for small, typed utilities like slug conversion, delays, previous-value tracking, and error normalisation without rewriting them in each project.
- โ Typed utility functions (e.g. sleep, slugify, short ID generator)
- โ๏ธ Server + client safe helpers
- ๐ช React hooks like usePrevious and useIsomorphicLayoutEffect
- ๐งช Unit tested with Jest
โจ Features
- โ Typed utility functions (e.g. sleep, slugify, short ID generator)
- โ๏ธ Server + client-safe helpers
- ๐ช React hooks like
usePreviousanduseIsomorphicLayoutEffect - ๐งช Unit tested with Jest
- ๐ฆ Lightweight and tree-shakable
Setup
Installation
Bring the package into your project with the published npm entrypoint.
npm install @batoanng/utils
๐ฆ Installation
npm install @batoanng/utils
Start
Pull utility functions and hooks from the package root
The package is tree-shakable, so consumers can import narrow helpers without paying for the full surface area.
import { sleep, toSlug, usePrevious } from '@batoanng/utils';
await sleep(250);
const previousValue = usePrevious(value);
const slug = toSlug('Design System Docs');
๐ Usage
import { sleep, generateShortId } from '@batoanng/utils';
import { usePrevious } from '@batoanng/utils';
Surface
Exports And Entrypoints
Export surface
.-> types:./dist/index.d.ts, import:./dist/index.js, require:./dist/index.cjs, default:./dist/index.js
Entrypoints
- main:
./dist/index.cjs - module:
./dist/index.js - types:
./dist/index.d.ts
Key files
eslint.config.mjsjest.config.cjspackage.jsonsrc/tsconfig.json
Integration
Integration Notes
Internal workspace links
@batoanng/eslint-config@batoanng/jest-config@batoanng/tsconfig@batoanng/types
Ops
Development Notes
Latest release snapshot
2.4.2
Patch Changes
- Replace published
workspace:*development dependency ranges with npm semver ranges.
๐งน Linting
This package uses the shared flat ESLint setup via eslint.config.mjs:
import base from '@batoanng/eslint-config/base';
import test from '@batoanng/eslint-config/test';
export default [...base, ...test];
Source docs
Reference
The full README is rendered below so the package guide stays detailed and traceable to the source docs that live with the package itself.
A collection of general-purpose utility functions and React hooks used across multiple packages and applications.
โจ Features
- โ Typed utility functions (e.g. sleep, slugify, short ID generator)
- โ๏ธ Server + client-safe helpers
- ๐ช React hooks like
usePreviousanduseIsomorphicLayoutEffect - ๐งช Unit tested with Jest
- ๐ฆ Lightweight and tree-shakable
๐ฆ Installation
npm install @batoanng/utils
๐ Usage
import { sleep, generateShortId } from '@batoanng/utils';
import { usePrevious } from '@batoanng/utils';
๐ Included Utilities
src/
โโโ generateShortId.ts # Short random string generator
โโโ getNormalisedError.ts # Transforms mixed errors to unified format
โโโ SearchSpecBuilder.ts # Siebel-like query builder for filters
โโโ sleep.ts # Delay function using Promise
โโโ toSlug.ts # Converts string to URL-friendly slug
โโโ useIsomorphicLayoutEffect.tsx # SSR-safe useLayoutEffect
โโโ usePrevious.tsx # React hook to get previous value
๐งน Linting
This package uses the shared flat ESLint setup via eslint.config.mjs:
import base from '@batoanng/eslint-config/base';
import test from '@batoanng/eslint-config/test';
export default [...base, ...test];