lil tool i use internally
npm install --save-dev abbreviatedjs
npx abv --file [.ajs file]
# ^^ To compile a file ^^
npx abv --dir [dir]
# ^^ To compile all the .ajs files in [dir]
use --ts
to use .ats files
In the form [{abbreviation}, {commonjs equivatent}]
[`lg`, `console.log`],
[`er`, `console.error`],
[`wrn`, `console.warn`],
[`cls`, `console.clear()`], // no parentheses needed, no args
[`vv`, `var`],
[`vl`, `let`],
[`vc`, `const`],
[`eq`, `==`],
[`seq`, `===`],
[`el`, `else`],
[`pl`, `+=`],
[`mn`, `-=`],
[`fun`,`function`],
[`as`, `async`],
[`aw`, `await`],
[`to_i`, `parseInt`],
[`to_f`, `parseFloat`],
[`err`, `new Error`],
[`tt`, `true`],
[`ff`, `false`],
[`dte`, `new Date`],
[`cth`, `catch`],
[`jp`, `JSON.parse`],
[`jst`, `JSON.stringify`],
[`brk`, `break`],
[`clss`, `class`],
[`expt`, `export`],
[`imp`, `import`],
[`req`, `require`],
[`ret`, `return`],
[`swt`, `switch`],
[`sta`, `static`],
[`fori`, ` for (let i = 0;`],
[`efori`, `; i++)`],
[`dft`, ` default`]
]
suffixes
[`.to_s`, `.toString()`],
fun main() {
fori i<100 efori {
lg(i.to_s);
}
/* >> '1'
* >> '2'
* >> ...
* >> '99'
*/
}
This script is a main() function that iterates 100 times 0..99, and prints stringified versions to the console.