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-jsfilename to complie the file to .js
- If you don't have
npxinstalled please install it to use this tool - The npx command will also watch for editings in that file in the background and
re-complieit - 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.jswill be created - You can now run
node index.jsornode .
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
logto console.loglog.traceto console.tracelog.errorto console.error
Note: writingconsole.logis not recommended but alloweduuidto generate a uuid example:uuid(5)(the agrument is the lenght of the uuid)modto import a module using requirefuncto define a functionintto do math opration example ini.random()minto get the min valuemaxto get the max valuerandomto get a random numberclampto clamp the valuefloorto round the value downceilto round the value uproundto round the valueabsto get the absolute valuesignto get the sign of the valuesrtto get the square root of the valuepowto get the power of the value
do.afterto run a function after a certain amount of time in millisecondsdo.everyto run a function every certain amount of time in millisecondsdo.cancelto 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