prunee
Version:
A series of packages.
118 lines (115 loc) • 2.81 kB
JavaScript
let vars = {}, chalk = require("chalk"),text;
class PVar {
constructor() {
console.log("Using PVar, native to PruneE Variable type; base contruct/class; T:V-def")
}
full() {
console.log("PVar<class> Define and set variables in Prune with extended variable options. \n\t>>> Full docs install prunee-var-docs or prunee-docs and enter in command line prunee-docs or prunee-var-docs, depending on what you chose.")
}
getvar(varname) {
if (!vars[varname]){
throw new TypeError("Variable " + varname + " does not exist. Try creating the variable before you get it. ENEX001")
} else {
return vars[varname]
}
}
define(varname,varval){
vars[varname] = varval
}
vardel(varname) {
if (!vars[varname]){
throw new TypeError("Variable " + varname + " does exist. Try creating the variable before you delete it. ENEX001")
} else {
delete vars[varname]
}
}
clear() {
vars = {}
}
check(varname) {
if (vars[varname]) {
return true
} else {
return false
}
}
valcheck(varname,val) {
if (!vars[varname]) {
throw new TypeError("Variable " + varname + " does exist. Try creating the variable before you delete it. ENEX001")
} else {
return vars[varname] === val
}
}
nodatavalcheck(varname,val) {
throw new Error("Support for this function is deprecated. You can use valcheck instead. EDEP002")
if (!vars[varname]) {
throw new TypeError("Variable " + varname + " does exist. Try creating the variable before you delete it. ENEX001")
} else {
return vars[varname] == val
}
}
makenull(varname) {
vars[varname] = null;
}
makeundefined(varname) {
vars[varname] = undefined;
}
}
class PMath {
constructor(funcs) {
console.log("Using PMath, native to PruneE Math type; base construct/class; T:M-op")
return 0;
}
add(x,y){
return x+y
}
subtract(x,y) {
return x-y
}
multiply(x,y) {
return x*y
}
divide(x,y) {
return x/y
}
power(x,y) {
return x**y
}
square(x,y) {
return Math.sqrt(x,y)
}
}
class PConsole {
constructor() {
console.log("Using PConsole, native to PruneE Console type; base contruct/class; T:C-print")
}
log(...txt) {
text = txt.join(' ')
console.log(text)
}
warn(...txt){
text = txt.join(' ')
console.log(chalk.bgYellow("WARNING:") + " " + chalk.yellow(text))
}
error(...txt){
text = txt.join(' ')
console.log(chalk.bgRedBright("ERROR:") + " " + chalk.redBright(text))
}
info(...txt){
text = txt.join(' ')
console.log(chalk.bgCyan("Info:") + " " + chalk.cyanBright(text))
}
success(...txt){
text = txt.join(' ')
console.log(chalk.bgGreen("SUCCESS!") + " " + chalk.green(text))
}
fail(...txt){
text = txt.join(' ')
console.log(chalk.rgb(255,165,0).inverse("FAILED:") + " " + chalk.rgb(255,165,0)(text))
}
}
module.exports = {
PVar,
PMath,
PConsole
}