A new NodeJs preprocess
to make it more easy and simple :)
What you need to know:
- All C-JS file end in .jsc
- Run
npx compile-js
filename to complie the file to .js
- If you don't have
npx
installed please install it to use this tool - The npx command will also watch for editings in that file in the background and
re-complie
it - After you run the command please edit the file so that it will start the compiler
- To get started make a file called
index.jsc
- Add the following code to the file:
import readline; var { stdin: input, stdout: output } = mod('process'); var line = readline.createInterface({ input, output }); func ask(qustion, callback){ line.question(qustion, callback); } ask('What is your name? ', (answer) => { console.log(`Hello ${answer}`); var name = answer; ask("What is your age? ", (answer2) => { console.log(`${name} is ${answer2} years old`); line.close() }); });
- Then run
npx compile-js index
or the filename without the extension - A new file called
index.js
will be created - You can now run
node index.js
ornode .
Note: the file given to the compiler must be in the same directory as where you run the command and if the jsc file is edited it will re-compile the file in the backgroud
log
to console.loglog.trace
to console.tracelog.error
to console.error
Note: writingconsole.log
is not recommended but alloweduuid
to generate a uuid example:uuid(5)
(the agrument is the lenght of the uuid)mod
to import a module using requirefunc
to define a functionint
to do math opration example ini.random()min
to get the min valuemax
to get the max valuerandom
to get a random numberclamp
to clamp the valuefloor
to round the value downceil
to round the value upround
to round the valueabs
to get the absolute valuesign
to get the sign of the valuesrt
to get the square root of the valuepow
to get the power of the value
do.after
to run a function after a certain amount of time in millisecondsdo.every
to run a function every certain amount of time in millisecondsdo.cancel
to cancel a function- import
- readline
- crypto
- fs
- path
- os
- process
- http
- https
- net
- tls
- dns
- url
- stream
- buffer
- v8
- util
- dgram
- assert
- events
- child_process
- domain
- module
to import them from node with the same name
This program also minifies the file using an API
to save space on a large file
This program is free and open source to all
If you find any error please report it at https://github.com/s0net/c-js/issues
If you have any suggestion please tell it in our disccusion option at https://github.com/s0net/c-js/diccusion