exten
Version:
exten module extend and advance your NodeJS.
118 lines (117 loc) • 2.06 kB
JavaScript
var valc={}
module.exports={
log:(e)=>{
console.log(e)
},
math:{
deg2rad:(e)=>{
return e*Math.PI/180
},
rad2deg:(e)=>{
return e*180/pi
},
sin:(e)=>{
return Math.sin(e)
},
cos:(e)=>{
return Math.cos(e)
},
tan:(e)=>{
return Math.tan(e)
},
e:Math.E,
pi:Math.PI,
ln2:Math.LN2,
ln10:Math.LN10,
log2e:Math.LOG2E,
log10e:Math.LOG10E,
abs:(e)=>{
return Math.abs(e)
},
cbrt:(e)=>{
return Math.cbrt(e)
},
rndb:()=>{
return Math.random()
//Note:Its return 0~1 area random number.
},
rnd:(e)=>{
return Math.floor(Math.random()*(e - -1))
},
floor:(e)=>{
return Math.floor(e)
},
sqrt:(e)=>{
return Math.sqrt(e)
}
},
bol:(e)=>{
if(e == 0){
return false
}else if(e == 1){
return true
}
return 'ValueError:Select 0 or 1.'
},
define:(a,b)=>{
valc[a]={}
valc[a].cont=b
},
view:(e)=>{
if(valc[e] == undefined){
return 'UndefinedError'
}
return valc[e].cont
},
typeis:(e)=>{
if(valc[e] == undefined){
return 'UndefinedError'
}
return (typeof valc[e].cont)
},
logic:{
NOT:(e)=>{
if((typeof e) == 'boolean'){
return !e
}else{
return 'ValueError:Select boolean'
}
},
XOR:(a,b)=>{
if(a != b){
if((typeof a) == 'boolean' && (typeof b) == 'boolean'){
return true
}else{
return 'ValueError:Select boolean'
}
}else{
return false
}
},
AND:(a,b)=>{
if(a == b){
if((typeof a) == (typeof b) && (typeof a) == 'boolean'){
return true
}else{
return 'ValueError:Select boolean'
}
}else{
return false
}
},
OR:(a,b)=>{
if((typeof a) == (typeof b) && (typeof a) == 'boolean'){
if(a || b){
return true
}else{
return false
}
}else{
return 'ValueError:Select boolean'
}
}
},
split:(a,b)=>{
return a.split(b)
}
}