koalacodes-utils v1.2.8
Koalacodes Utils
Useful package with functions for js
This program works okay in javascript but since some of the type restrictions will go away, please try to use it in typescript.
Installation:
npm install koalacodes-utils
After installing using npm you can import it as follows:
import * as Utils from "koalacodes-utils";
\
Each function below will be in the format of Object.functionCall()
so to call an example function String.reverse()
or as follows:
var myString = "Hello World!"; // Creates myString variable
myString = myString.reverse(); //Compared this to the previous myString = reverse(myString)
console.log(myString); // Returns "!dlroW olleH"
All functions are non-mutable, meaning you will need to reassign the function to the variable for every one of the below.
Update Log
1.2.8
- Numbers has been changed to Math and now works with the rest of the code
1.2.7
Reworked the system in which to use koalacodes-utils, removed/reworked a couple functions, please review the above and below on how to use the document - Dec 27th 2023
NOTE:
This project was originally discontinued but is now coming back! - Dec 26th 2023
0.2.7
Added a new function - May 9th, 2023
0.2.6
0.2.5 patch didn't work, fixed that - May 8th, 2023
NOTE:
0.2.3 and the rest through 0.2.5 were all deprecated due to me forgetting to transpile the index.ts. Main Updates: Bug fixes for 0.2.4 and 0.2.5 And some changes to functions - May 8th, 2023
0.1.3
Updated README.md(sorry about the wrong installation phrase) - May 3rd, 2023
0.1.2
Added 6 new functions - May 3rd, 2023
0.0.2
Added Update Log - May 2nd, 2023
0.0.1
Changed README.md - May 2nd, 2023
0.0.0
First Published - May 2nd, 2023
Happy Coding!
All Functions
Arrays
Array.alphabetize():
Call with: Array.alphabetize(reversed)
Description: Sorts an array in alphabetical order
Arguments:
array(array) - The array you want to sort
reversed(boolean) - True: sort the array z-a, False: sort the array a-z
Need-To-Knows: Array.alphabetize(reversed) will only take in arrays with strings and is non-mutable
Array.numericalize():
Call with: Array.numericalize(reversed)
Description: sorts an array greatest to least or least to greatest
Arguments:
reversed(boolean) - True: greatest to least, False: least to greatest
Need-To-Knows: Array.numericalize(reversed) only takes in arrays with numbers
Array.countValue():
Call with: Array.countValue(value)
Description: Counts the amount of a certain value in a given array
Arguments:
value(any) - The value you want to count
Need-To-Knows: Array.countValue(value) will return a number and is case-sensitive
Array.randomElement():
Call with: Array.randomElement()
Description: Gets a random element in a given array
Arguments:
None
Need-To-Knows: Array.randomElement() can contain arrays inside of it
Array.removeItemAll():
Call with: Array.removeItemAll(value)
Description: Removes all instances of a value from an array
Arguments:
value(any) - What value you want to remove(Must be in the array)
Need-To-Knows: Array.removeItemAll(value) removes ALL instances of the value
Array.removeItemOnce():
Call with: Array.removeItemOnce(value)
Description: Removes the first instance of a value from an array
Arguments:
value(any) - What value you want to remove(Must be in the array)
Need-To-Knows: Utils.removeItemOnce(array, value) only removes the value once
Math
Math.randomInt():
Call with: Math.randomInt(min, max)
Description: Gets a random whole number between min and max
Arguments:
min(int) - Minimum number in the range
max(int) - Maximum number in the range
Need-To-Knows: Math.randomInt(min, max) will automatically convert your min and max to whole numbers.
Math.randomNum():
Call with: Math.randomNum(min, max)
Description: Gets a random number between min and max
Arguments:
min(num) - Minimum number in the range
max(num) - Maximum number in the range
Need-To-Knows: Math.randomNum(min, max) will give you a decimal rounded to the nearest hundredth
String
String.reverse():
Call with: String.reverse()
Description: Reverses a string
Arguments:
none
Need-To-Knows: String.reverse() is non-mutable