-
Notifications
You must be signed in to change notification settings - Fork 63
Console Library
maximecb edited this page Sep 25, 2014
·
4 revisions
Higgs has a library to to allow you to pretty-print objects/data to stdout and read input from stdin.
Importing:
// To us use the console functions you must import the console module:
var console = require('lib/console');
Functions:
// To pretty-print
console.log("foo");
console.log({ foo: "bar"});
// If you pass multiple arguments, they are printed on the same line separated by tabs
console.log(1, 2, 3);
// Use console.prompt to prompt users for input.
// console.prompt(takes an optional "string" or value as a prompt message)
console.prompt("Enter you name:");
// Examples to assign the input to a variable.
var username = console.prompt("Choose a username:");
// Include a prompt with eval into your programs as a testing / development tool
var testvalue1 = eval(console.prompt("test expression 1:"));
// Higgs REPL
// test expression 1:
// 1+2
// h> testvalue1;
// 3