https://github.com/tmcw/incremental-eval
run javascript line-by-line
https://github.com/tmcw/incremental-eval
Last synced: 9 months ago
JSON representation
run javascript line-by-line
- Host: GitHub
- URL: https://github.com/tmcw/incremental-eval
- Owner: tmcw
- Created: 2013-03-04T21:50:52.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2020-06-13T23:35:14.000Z (about 6 years ago)
- Last Synced: 2025-02-06T14:11:51.926Z (over 1 year ago)
- Language: JavaScript
- Homepage: http://mistakes.io/
- Size: 6.84 KB
- Stars: 9
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## incremental-eval
[](http://ci.testling.com/tmcw/incremental-eval)
Given a string of javascript code, returns the result of running the code
line-by-line.
## install
npm install --save incremental-eval
## example
```js
var incr = require('incremental-eval');
incr('a = 2'); // [2]
incr('a = 2\n a * 2'); // [2, 4]
// supports modifying the scope with with
incr('a', { a: 2 }); // [2]
```
### incrementalEval()
Takes a piece of Javascript code, as a string, and returns an array of results
per-line. If a line does not return results, it is in the array as null.
The second argument can be an object that is supplied to `with`, so that
[you can change the scope of the eval](https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Statements/with)
## license
BSD