A versatile TypeScript library providing utility functions for array manipulation, string operations, and basic arithmetic.
npm install youssef-lib06
import { filterWords, reverseString, quickSort, add, evenOnly } from 'youssef-lib06';
// Examples
const sortedArray = quickSort([3, 1, 4, 1, 5, 9, 2, 6, 5, 3, 5]);
const reversedString = reverseString('hello');
const filteredWords = filterWords(['the', 'dog', 'got', 'a', 'bone'], 'ae');
const sum = add(1, 2);
const evenNumbers = evenOnly([1, 3, 5, 2, 4, 6]);
API
quickSort(arr: number[]): number[]
Sorts an array of numbers in ascending order.
reverseString(str: string): string
Reverses the given string.
filterWords(words: string[], letters: string): string[]
Filters an array of words, returning only those containing any of the specified letters.
add(a: number, b: number): number
Adds two numbers.
evenOnly(arr: number[]): number[]
Returns an array containing only the even numbers from the input array.
Testing
To run the tests:
bash
npm test
License
ISC License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.