A JavaScript virtual operating system, in your browser. Created by Michael Bilstein and Scott Mangiapane. It currently supports a limited range of commands, but more are coming soon!
https://twoduck.github.io/nix.js
-
You should have only one user-facing function, with all helper functions scope restricted.
- Your primary function should be declared like:
function myFunction(args)
- Any helper functions should be scope restricted, using
const
:const myHelper = function()
- Your primary function should be declared like:
-
Your primary function should be the title of your program (hello.js should have a public hello function).
-
Your primary function will receive an array of arguments that the user gives to it.
- For example,
$echo hello there
results inargs
===["hello", "there"]
in theecho(args)
function call.
- For example,
- Where
text
is the text you want printed to a new line. - Returns the index of the line you just created.
- Where
index
is the index of the line you want to change. - And
text
is the text you want the line to be changed to. - Note that you have unlimited access with this function, and can end up changing lines you didn't indend to if you aren't careful.
function helloNameAndDate(args) {
if (!args[0]) {
addLine("Please provide a name.");
return;
}
const name = args[0];
const date = getDate();
addLine(`Hello, ${name}. It is: ${date}`);
}
const getDate = function() {
const clock = new Date();
return `${clock.toDateString()}, ${clock.toTimeString()}`;
};
In order to submit a package to be added to the repository, just make a pull request with your package in the js/programs folder. We will review your package and merge if it follows the guidelines provided.