@raadsel/smallify v1.0.8
Smallify
Originally made for documatics hackathon.
Actual content:
I am very new to NPM packages so this is my first one! I hope it is something useful/good!
How to install
Run this command
$ npm install @raadsel/smallifyHow to use
You can import all the short functions adding this line:
const { log, print, clear, int, float, sleep, random, randomColor, randomColorRGB, round, ev, getenv, setenv, UUID } = require("@raadsel/smallify");- log, => alternative console.log
 - print, => alternative console.log
 - clear, => shorter console.clear. Clears console
 - str, => converts object to string
 - int, => converts object to int
 - float, => converts object to float
 - sleep, => sleep and continue after that. Usage: sleep(miliseconds)
 - random, => random number between min and max
 - randomColor, => Gets a random Hex color
 - randomColorRGB, => Gets a random RGB color
 - randomColorRGBA, => Gets a random RGBA color
 - round, => Rounds number to decimals
 - ev, => shorter eval
 - getenv, => alternative to process.env.SECRET. Gets the environment variable
 - setenv, => set environment variable ; alternative to process.envenv = value
 - allenvs, => get all environment variables
 - UUID, => generate a random UUID
 
Now the more detailed explanation
You can use the log() or print() function as a replacement for console.log(). And the clear() function as a replacement for console.clear() \
Example:
const { log, print, clear } = require("@raadsel/smallify");
log("Hello world!")
//=> Hello world!
print("Hello NPM!")
//=> Hello NPM!
//to clear the console
clear()You can use the str() function to convert an object to a string \
Example:
const { str, log} = require("@raadsel/smallify");
const integer = 1
const inttostring = str(integer)
log(inttostring)
//=> 1
// but now it is an string!You can use the int() function to convert an object to a integer! \
Or use the float() function to convert an object to a float! \
Example:
const { int, float, log} = require("@raadsel/smallify");
const string1 = "1"
const string2 = "2"
const float1 = "1.9"
const float2 = "1.1"
log(int(string1)+int(string2))
//=> 3
log(float(float1)+float(float2))
//=> 3
//this won't work if its a string
log(string1+string2)You can use the random(num1, num2) function to get a random nummer between 2 inputted values. By default it's 0,100 \
Example:
const { print, random } = require("@raadsel/smallify");
print(random())
//=> random number between 0 and 100
//or like this
print(random(0,5))
//=> random number between 0 and 5Now for the random colors: \
There are 3 random colors functions: randomColor() (returns a random hex color), randomColorRGB() (returns a random RGB color) and randomColorRGBA() (returns a random RGBA color).  \
Usage: 
const { print, randomColor, randomColorRGB, randomColorRGBA } = require("@raadsel/smallify");
print(randomColor())
//=> #387687
// (random hex)
print(randomColorRGB())
//=> rgb(213,187,1)
// (random RGB)
print(randomColorRGBA())
//=> rgba(60,93,176,72)
// (random RGBA)The round() function rounds a number to a decimal. \
Usage: \
round(1.23456789, 3) 
//=> 1.235You can use ev() as shorter/replacement for eval(). And the sleep() function pauzes the code for a specific time. Kinda like the python time.sleep() function. \
Example: 
const { clear, log, sleep} = require("@raadsel/smallify");
ev("log('SPAM\nSPAM\nSPAM\nSPAM\nSPAM\nSPAMSPAMSPAM')")
//=> a lot of spam in the console
//using sleep() to not instantly clear the console so you can still see it
sleep(1000)
clear()
//=> 
//console is clearedThe getenv("ENV") version is an shorter version of process.env.[ENV], and the setenv("FOO", "BAR") is a shorter function of procces.env.[ENV] = value] \
Usage example: 
.env file:
FOO=barindex file:
const { log, getenv} = require("@raadsel/smallify");
log(getenv("FOO"))
//=> BARor \
.env file:
index file:
const { log, getenv, setenv} = require("@raadsel/smallify");
setenv("FOO", "BAR")
log(getenv("FOO"))
//=> BARThere's also the getenvs() function which gives ALL the envs there are
The UUID() function returns a random UUID (Universally unique identifier)
const { log, UUID} = require("@raadsel/smallify");
log(UUID())
//=> 1dda2536-3cc3-4978-a82c-a0f202916ac1 (this is random)That's it, simple but powerful!