Skip to content

Instantly share code, notes, and snippets.

@kusor
Created December 31, 2009 08:56
Show Gist options
  • Save kusor/266676 to your computer and use it in GitHub Desktop.
Save kusor/266676 to your computer and use it in GitHub Desktop.
Smart JavaScript Console
/*
Smart JavaScript Console:
$ cd /Applications/Smart.app/Contents/Resources/Image
$ ./bin/js
*/
js> help();
JavaScript-C 1.8.0 pre-release 1 2007-10-03
Command Description
======= ===========
version([number]) Get or set JavaScript version number
options([option ...]) Get or toggle JavaScript options
load(['foo.js' ...]) Load files named by string arguments
readline() Read a single line from stdin
print([exp ...]) Evaluate and print expressions
help([name ...]) Display usage and help messages
quit() Quit the shell
assertEq(actual, expected)
Throw if the two arguments are not ===
gc() Run the garbage collector
gcparam(name, value)
Wrapper for JS_SetGCParameter. The name must be either 'maxBytes' or
'maxMallocBytes' and the value must be convertable to a positive uint32
countHeap([start[, kind]])
Count the number of live GC things in the heap or things reachable from
start when it is given and is not null. kind is either 'all' (default) to
count all things or one of 'object', 'double', 'string', 'function',
'qname', 'namespace', 'xml' to count only things of that kind
trap([fun, [pc,]] exp) Trap bytecode execution
untrap(fun[, pc]) Remove a trap
line2pc([fun,] line) Map line number to PC
pc2line(fun[, pc]) Map PC to line number
stackQuota([number]) Query/set script stack quota
stringsAreUTF8() Check if strings are UTF-8 encoded
testUTF8(mode) Perform UTF-8 tests (modes are 1 to 4)
throwError() Throw an error from JS_ReportError
build() Show build date and time
clear([obj]) Clear properties of object
intern(str) Internalize str in the atom table
clone(fun[, scope]) Clone function object
seal(obj[, deep]) Seal object, or object graph if deep
getpda(obj) Get the property descriptors for obj
getslx(obj) Get script line extent
toint32(n) Testing hook for JS_ValueToInt32
evalcx(s[, o])
Evaluate s in optional sandbox object o
if (s == '' && !o) return new o with eager standard classes
if (s == 'lazy' && !o) return new o with lazy standard classes
shapeOf(obj) Get the shape of obj (an implementation detail)
snarf(filename) Read filename into returned string
timeout([seconds])
Get/Set the limit in seconds for the execution time for the current context.
A negative value (default) means that the execution time is unlimited.
elapsed() Execution time elapsed for the current context.
js> quit();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment