py.th

1.0.7 • Public • Published

py.th

What is py.th?
py.th contains some of the basic python functions in JavaScript.
Why use py.th?
py.th not only allows you to import files and libraries (2 currently) it also allows you to make functions, using the def keyword. Here are some examples:

const { print, def, lower, upper, importLib, importFile } = require('py.th');
print("Hello") //->Hello
print(lower("HELLO")) //->hello
print(upper("hello")) //->HELLO
print() //-> Prints a new line
const time = importLib("time");
time.sleep(() => {
    print("I ran after 2 seconds") //Importing the time module allows you to sleep for certain amounts of time, so you can exectue code
},2000);
const clear = importlib("clear");
clear.clear();
//Clears the whole console
const myFunction = def("cheese","sauce",(cheese, sauce) => {
    print(cheese);
    print(sauce);
})
//Now, when I call myFunction, it will execute the code inside the arrow function when defining. You can have as many params as you want but the params take in strings, no other type is accepted. 
//Lets call it
myFunction("cheddar","tomato") //Logs cheddar and sauce, because that is what the function does!

Modules/Libraries
time > sleep > time.sleep(callback-function,time_in_ms) : Sleeps x amount of time then executes the callback
py.th > randomArray > pyth.randomArray(["hello","hi"]) : Grab a random object from an array
clear > clear > clear.clear() : Clear the console
random > random > random.randint(5) : Generate a number between 0 and your number

All libraries can be imported with importLib("module") (If importLib is imported from py.th)

Package Sidebar

Install

npm i py.th

Weekly Downloads

0

Version

1.0.7

License

ISC

Unpacked Size

4.77 kB

Total Files

16

Last publish

Collaborators

  • salvage_dev