Lightweight, type-safe array utility functions
npm install @amitchandmandal/array-utilsYou 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:
```md
`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-utils
`
Or with yarn:
bash
`
yarn add @amitchandmandal/array-utils
`
---
Usage
$3
ts
`
// ES Modules
import { uniqueNumbers, getLargest, getSmallest } from '@amitchandmandal/array-utils';
// CommonJS
const { uniqueNumbers, getLargest, getSmallest } = require('@amitchandmandal/array-utils');
`
$3
#### Remove duplicates from an array
ts
`
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
ts
`
const numbers = [1, 5, 2, 9, 3];
const largest = getLargest(numbers);
console.log(largest); // 9
`
#### Find the smallest number in an array
ts
`
const numbers = [1, 5, 2, 9, 3];
const smallest = getSmallest(numbers);
console.log(smallest); // 1
uniqueNumbers
---
API
| Function | Description | Parameters | Returns |
| --------------- | ---------------------------------------- | ----------------- | -------- |
| | 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:
ts
``
import { uniqueNumbers } from '@amitchandmandal/array-utils';
---