reval

0.1.1 • Public • Published

reval Build Status

A JavaScript lib for building continuous execution style programming interfaces like these.

Install

npm install reval

Examples

Require it.

var reval = require('reval');

Evaluate some JavaScript.

function src() {
	return 2 + 2 + 2;
}

console.info(reval(src.toString()).run()); // 6

Print all local variables.

function locals() {
  var x = 2
    , y = 3;

  return x * y;
}

var ctx = reval(locals.toString());

ctx.watch(function(name, val) {
  console.info(arguments);
});

ctx.run();

Output

['x', 2]
['y', 3]

Infinite recursion protection.

function bad() {
  while(true) {
    // infinte loop
  }

  for(var i = 0; true; i++) {
    // infinite loop
  }
}

reval(bad.toString()).run();

console.info('...nope still here!');

Tests

make test

In the browser

Works in the browser with browserify.

License

MIT/X11

Readme

Keywords

none

Package Sidebar

Install

npm i reval

Weekly Downloads

2

Version

0.1.1

License

none

Last publish

Collaborators

  • ritch