What do you mean about a caveat for Socket.bytesPending?
kb.getString() is there, except I named it kb.keyString() instead. Not sure which name is better, probably getString.
const random = require('random');// 25% chance this is trueconsole.log(random.chance(0.25));// integer [1,10]console.log(random.discrete(1, 10));// expected value 1000, std. dev. 50console.log(random.normal(1000, 50));// 10 alphanumeric charactersconsole.log(random.string(10));// one of: pig, cow, apevar array = [ "pig", "cow", "ape" ];console.log(random.sample(array));
maggie.eat(allOfEverything);assert(maggie.weight >= 812, "maggie isn't fat enough");maggie.sitOn(scott);
ssj.trace("engine is " + system.name);ssj.trace("mouse at x:" + mouse.x + ",y:" + mouse.y);var start = system.now();system.sleep(2.0);var end = system.now();ssj.trace("slept for " + (end - start) + " secs");
SSJ.trace("engine is " + System.name);SSJ.trace("mouse at x:" + Mouse.x + ",y:" + Mouse.y);var start = System.now();System.sleep(2.0);var end = System.now();SSJ.trace("slept for " + (end - start) + " secs");
Should assert() and trace() ("print to debugger") be global functions? In minisphere 4.0 they are referenced as e.g. ssj.assert() (i.e. a minisphere extension), but I can change them to global if anyone thinks this should be standard functionality.
require('assert');assert();
That said, couldn't assert be a library? I think if system calls ought to be few, certainly assertions could be in a library with system logging/debugging calls being what the library would use anyways.
exports.assert = function(test, msg) { system._assert(test, msg); }exports.trace = function(msg) { system._trace(msg); }