@amitchandmandal/array-utils
v1.0.1
Published
Lightweight, type-safe array utility functions
Readme
You can copy the entire block below exactly as it is and save it in your package folder as README.md. This is a fully formatted, ready-to-use README for your @amitchandmandal/array-utils package:
# Array Utils
A small, lightweight utility library for working with arrays in JavaScript and TypeScript.
Provides helpful functions like removing duplicates, finding the largest/smallest element, and more.
---
## Installation
Install via npm:
```bash
npm install @amitchandmandal/array-utilsOr with yarn:
yarn add @amitchandmandal/array-utilsUsage
Importing
// ES Modules
import { uniqueNumbers, getLargest, getSmallest } from '@amitchandmandal/array-utils';
// CommonJS
const { uniqueNumbers, getLargest, getSmallest } = require('@amitchandmandal/array-utils');Examples
Remove duplicates from an array
const numbers = [1, 2, 2, 3, 3, 4];
const unique = uniqueNumbers(numbers);
console.log(unique); // [1, 2, 3, 4]Find the largest number in an array
const numbers = [1, 5, 2, 9, 3];
const largest = getLargest(numbers);
console.log(largest); // 9Find the smallest number in an array
const numbers = [1, 5, 2, 9, 3];
const smallest = getSmallest(numbers);
console.log(smallest); // 1API
| Function | Description | Parameters | Returns |
| --------------- | ---------------------------------------- | ----------------- | -------- |
| uniqueNumbers | Removes duplicates from an array | array: T[] | T[] |
| getLargest | Returns the largest element in an array | array: number[] | number |
| getSmallest | Returns the smallest element in an array | array: number[] | number |
TypeScript Support
This package includes TypeScript types. You can import it directly in TypeScript projects:
import { uniqueNumbers } from '@amitchandmandal/array-utils';Contributing
Contributions, suggestions, and bug reports are welcome! Feel free to open an issue or a pull request.
When contributing, please make sure to:
- Follow consistent coding style
- Add tests for new functionality
- Update documentation if needed
