UNPKG

maheshjs

Version:

This package helps you in solving day to day various simple challenges and makes you write code faster

49 lines (38 loc) 2.15 kB
# maheshjs<br/> ![npm](https://img.shields.io/npm/v/maheshjs)<br/> ![license](https://img.shields.io/badge/license-MIT-blue.svg)<br/> ## Introduction<br/> `maheshjs` is a utility library that provides a set of functions for common operations such as string manipulation, random number generation, and mathematical calculations. This package is designed to simplify your coding tasks and improve productivity.<br/> ## Current Functions<br/> 1. **getString**<br/> - **Description**: Returns a string based on specified criteria.<br/> - **Usage**: `getString(criteria)`<br/> - **Example**: `getString('example')` returns `'example'`.<br/> 2. **getRandomInt**<br/> - **Description**: Generates a random integer between two specified values.<br/> - **Usage**: `getRandomInt(min, max)`<br/> - **Example**: `getRandomInt(1, 10)` returns a random integer between 1 and 10.<br/> 3. **getRandomFloat**<br/> - **Description**: Generates a random floating-point number between two specified values.<br/> - **Usage**: `getRandomFloat(min, max)`<br/> - **Example**: `getRandomFloat(1.0, 10.0)` returns a random float between 1.0 and 10.0.<br/> 4. **isEven**<br/> - **Description**: Checks if a number is even.<br/> - **Usage**: `isEven(number)`<br/> - **Example**: `isEven(4)` returns `true`.<br/> 5. **isOdd**<br/> - **Description**: Checks if a number is odd.<br/> - **Usage**: `isOdd(number)`<br/> - **Example**: `isOdd(5)` returns `true`.<br/> 6. **getAverageByNumbersArray**<br/> - **Description**: Calculates the average of an array of numbers.<br/> - **Usage**: `getAverageByNumbersArray(numbersArray)`<br/> - **Example**: `getAverageByNumbersArray([1, 2, 3, 4])` returns `2.5`.<br/> 7. **hasDateTimePassed**<br/> - **Description**: Checks if a given date and time has passed.<br/> - **Usage**: `hasDateTimePassed(dateTime)`<br/> - **Example**: `hasDateTimePassed(new Date('2025-01-01'))` returns `true` if the date has passed.<br/> ## Installation<br/> To install the package, run the following command:<br/> ```bash npm install maheshjs