mmzaghlool
v1.2.1
Published
Typescript general lib
Downloads
1
Maintainers
Readme
Typescript utils for js/ts
General lib to make your life easier based on typescript
Installation
npm i mmzaghlool
Importing
ES5
const MMZaghlool = require("mmzaghlool");
const { sortingTypes } = require("mmzaghlool");
ES6
import MMZaghlool, { sortingTypes } from "mmzaghlool";
Recursion Sum
Get the sum of array of numbers based on recursion algorithm it takes an array of numbers and return single number "Sum"
const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];
MMZaghlool.Math.recursionSum(arr);
Sorting
Section Sort
Sort array of numbers or objects ascending or descending using selection sort algorithm
It takes an array of numbers or objects and return the sorted array
// Sort array of numbers
const arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
MMZaghlool.Math.sectionSort(arr1, sortingTypes.DESCENDING)
// Sort array of objects based on "id" attribute
const arr2 = [{ id: 5 }, { id: 7 }, { id: 3 }, { id: 2 }, { id: 9 }];
MMZaghlool.Math.sectionSort(arr2, sortingTypes.ASCENDING, "id")
Quick Sort
Sort array of numbers or objects ascending or descending using quick sort algorithm
It takes an array of numbers or objects and return the sorted array
// Sort array of numbers
const arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9];
MMZaghlool.Math.quickSort(arr1, sortingTypes.DESCENDING)
// Sort array of objects based on "id" attribute
const arr2 = [{ id: 5 }, { id: 7 }, { id: 3 }, { id: 2 }, { id: 9 }];
MMZaghlool.Math.quickSort(arr2, sortingTypes.ASCENDING, "id")
Reach Me
If you need any help or any suggestions feel free to contact me anytime