@tantrija/helper-functions v1.2.0
@tantrija/helper-functions
A comprehensive collection of 500+ helper functions for strings, arrays, numbers, objects, and dates.
Table of Contents
- Overview
- Installation
- Features
- Function Categories
- Quick Examples
- API Reference
- Contributing
- Support
- License
Overview
@tantrija/helper-functions
is a type-safe, modular utility library containing 500+ helper functions for day-to-day development tasks, including:
✅ Strings: Manipulate, format, and validate strings.
✅ Arrays: Sort, group, and flatten arrays efficiently.
✅ Numbers: Perform calculations, validations, and conversions.
✅ Objects: Merge, flatten, and transform objects.
✅ Dates: Format, calculate, and manipulate dates easily.
This library is optimized for JavaScript and TypeScript projects, focusing on performance, type safety, and simplicity.
Installation
Install via npm or yarn:
Using npm:
npm install @tantrija/helper-functions
Using yarn:
yarn add @tantrija/helper-functions
Features
- 📦 500+ Helper Functions: Prebuilt utilities to simplify repetitive tasks.
- ⚡ Modular Imports: Import only the functions you need to optimize bundle size.
- 🛠️ Type-Safe: Fully written in TypeScript for better IntelliSense and static checks.
- 🚀 Performance Optimized: Functions are lightweight and efficient.
- ✅ Well-Tested: Includes extensive test coverage to ensure reliability.
- 📚 Easy Documentation: Organized functions with clear usage examples.
Function Categories
Each category contains 100+ functions to streamline your workflow:
Category | Description | Examples of Functions |
---|---|---|
Strings | String manipulation, formatting, and validation. | capitalize , toSnakeCase , trim , truncate |
Arrays | Array sorting, filtering, and transformations. | flattenToDepth , uniqueByKey , groupByKey |
Objects | Object merging, validation, and key-value operations. | deepMerge , pickKeys , flattenObject |
Numbers | Number calculations, formatting, and utilities. | isPrime , factorial , randomInRange |
Dates | Date formatting, comparison, and manipulation. | formatDate , addDays , isLeapYear |
Quick Examples
1. String Utilities
import { capitalize, toSnakeCase } from '@tantrija/helper-functions/string';
console.log(capitalize('hello world')); // Output: "Hello world"
console.log(toSnakeCase('Hello World Example')); // Output: "hello_world_example"
2. Array Utilities
import { flattenToDepth, uniqueByKey } from '@tantrija/helper-functions/array';
const nestedArray = [1, [2, [3, [4]]]];
console.log(flattenToDepth(nestedArray, 2)); // Output: [1, 2, 3, [4]]
const data = [{ id: 1 }, { id: 2 }, { id: 1 }];
console.log(uniqueByKey(data, 'id'));
// Output: [{ id: 1 }, { id: 2 }]
3. Object Utilities
import { deepMerge, flattenObject } from '@tantrija/helper-functions/object';
const obj1 = { a: 1, b: { c: 2 } };
const obj2 = { b: { d: 3 } };
console.log(deepMerge(obj1, obj2));
// Output: { a: 1, b: { c: 2, d: 3 } }
console.log(flattenObject({ a: { b: { c: 1 } } }));
// Output: { "a.b.c": 1 }
4. Number Utilities
import { isPrime, factorial } from '@tantrija/helper-functions/number';
console.log(isPrime(7)); // Output: true
console.log(factorial(5)); // Output: 120
5. Date Utilities
import { formatDate, addDays } from '@tantrija/helper-functions/date';
console.log(formatDate(new Date(), 'YYYY-MM-DD')); // Output: "2024-06-15"
console.log(addDays(new Date(), 7)); // Adds 7 days to the current date.
API Reference
For the full list of 500+ functions and their usage, visit the:
📖 Full API Documentation
The documentation includes detailed descriptions, parameter explanations, and usage examples for each function.
Contributing
We welcome contributions! To contribute:
- Fork the repository on GitHub.
Clone the forked repository:
git clone https://github.com/tantrija/js-helper.git cd js-helper
Install dependencies:
npm install
Add or modify functions under
src/
and write tests intests/
.Run tests to ensure everything works:
npm test
Submit a Pull Request.
For detailed contribution guidelines, see the CONTRIBUTING.md.
Support
For issues, feature requests, or questions:
- Open an Issue: GitHub Issues
- Contact Support: admin@tantrija.com
License
This project is licensed under the MIT License. See the LICENSE file for more details.
If you find @tantrija/helper-functions
helpful, please ⭐ star the repository on GitHub. 🚀
Future Enhancements
- Additional utility functions for other data types.
- Support for performance monitoring and optimization.
- Integration with other frameworks like React and Node.js.