dt-common-utils
v1.0.0
Published
A fully typed utility library
Maintainers
Readme
DT Utils
A fully typed utility library for TypeScript projects.
Features
- 🔒 Fully Typed: Complete TypeScript support with strict type checking
- 🚀 Modern: Built with modern JavaScript/TypeScript features
- 📦 Tree-shakable: Only import what you need
- 🧪 Well Tested: Comprehensive test coverage
- 📚 Well Documented: JSDoc comments for all functions
Installation
npm install dt-utilsUsage
import { debounce, throttle, deepClone } from "dt-utils";
// Debounce a function
const debouncedSearch = debounce((query: string) => {
console.log("Searching for:", query);
}, 300);
// Throttle a function
const throttledScroll = throttle(() => {
console.log("Scroll event");
}, 100);
// Deep clone an object
const original = { a: 1, b: { c: 2 } };
const cloned = deepClone(original);Development
Prerequisites
- Node.js >= 16.0.0
- npm
Setup
- Clone the repository
- Install dependencies:
npm install
Available Scripts
npm run build- Build the librarynpm run dev- Watch mode for developmentnpm test- Run testsnpm run test:watch- Run tests in watch modenpm run lint- Run ESLintnpm run lint:fix- Fix ESLint issuesnpm run clean- Clean build directory
Building
npm run buildThis will compile TypeScript to JavaScript and generate type definitions in the dist/ directory.
Testing
npm testPublishing
npm publishAPI Documentation
Functions
debounce<T extends (...args: any[]) => any>(func: T, wait: number): T
Creates a debounced version of a function.
throttle<T extends (...args: any[]) => any>(func: T, limit: number): T
Creates a throttled version of a function.
deepClone<T>(obj: T): T
Creates a deep clone of an object.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Run tests and linting
- Submit a pull request
License
MIT
