mmzaghlool

1.2.1 • Public • Published

Typescript utils for js/ts

General lib to make your life easier based on typescript

NPM NPM

Installation

npm i mmzaghlool

Importing

ES5

const MMZaghlool = require("mmzaghlool");
const { sortingTypes } = require("mmzaghlool");

ES6

import MMZaghlool, { sortingTypes } from "mmzaghlool";
  1. Recursion Sum
  2. Sorting

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

LinkedIn profile Gmai account

Package Sidebar

Install

npm i mmzaghlool

Weekly Downloads

0

Version

1.2.1

License

ISC

Unpacked Size

17.8 kB

Total Files

10

Last publish

Collaborators

  • mmzaghlool