Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mmzaghlool/js-lib
https://github.com/mmzaghlool/js-lib
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/mmzaghlool/js-lib
- Owner: mmzaghlool
- Created: 2021-07-22T12:21:46.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-07-23T15:48:18.000Z (over 3 years ago)
- Last Synced: 2024-11-03T23:22:48.254Z (12 days ago)
- Language: TypeScript
- Size: 14.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# Typescript utils for js/ts
General lib to make your life easier based on typescript
[![NPM](https://img.shields.io/npm/v/mmzaghlool)](https://www.npmjs.com/package/mmzaghlool)
[![NPM](https://img.shields.io/npm/dt/mmzaghlool)](https://www.npmjs.com/package/mmzaghlool)## Installation
```bash
npm i mmzaghlool
```## Importing
### ES5
```javascript
const MMZaghlool = require("mmzaghlool");
const { sortingTypes } = require("mmzaghlool");
```### ES6
```javascript
import MMZaghlool, { sortingTypes } from "mmzaghlool";
```1. [Recursion Sum](#recursion-sum)
2. [Sorting](#sorting)
- [Section Sort](#section-sort)
- [Quick Sort](#quick-sort)## Recursion Sum
Get the sum of array of numbers based on recursion algorithm it takes an array of numbers and return single number "Sum"
```javascript
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
```javascript
// 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
```javascript
// 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