This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Sorts array in ascending order | |
function quickSort(arr) { | |
if (arr == null | |
|| !Array.isArray(arr)) return; | |
mQuickSort(arr, 0, arr.length); | |
function mQuickSort(arr, startIdx, endIdx) { | |
if (endIdx - startIdx <= 1) return; | |
if (endIdx - startIdx == 2 && arr[0] > arr[1]) { | |
var t = arr[1]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Made as proof of concept - malulleybovo@2019 | |
// A simple and fair array shuffle algorithm | |
var randomizeArray = function(arr) { | |
if (arr == null || !Array.isArray(arr)) return []; | |
arr = arr.slice(0); | |
var randArr = []; | |
while (arr.length > 1) { | |
randArr.push(arr.splice( | |
Math.floor(Math.random() * arr.length), 1)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* iLog : intelligent logger. | |
* Supports : .log(), .warn(), .error(), and .info() | |
* Configuring : | |
* Change iLogCfg to your fit. | |
* Supports color changes and enable/disable stack trace for each of the log functions | |
* Use : | |
* console.ilog('my comment'); | |
* -> my comment | |
* console.ilog(myVar1, myVar2, [more...]); |