Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

split out assign() from run()

  • Loading branch information...
commit ea806b81ecb55a21b040890a3840403eb89dc6b6 1 parent 905e01a
@substack authored
Showing with 15 additions and 5 deletions.
  1. +6 −0 README.markdown
  2. +8 −4 index.js
  3. +1 −1  package.json
View
6 README.markdown
@@ -68,7 +68,13 @@ b.compile()
Return the source wrapped with burrito.
+b.assign(context={})
+--------------------
+
+Assign the statement-tracking functions into `context`.
+
b.run(context={})
-----------------
Run the source using `vm.runInNewContext()` with some `context`.
+The statement-tracking functions will be added to `context` by `assign()`.
View
12 index.js
@@ -59,12 +59,11 @@ Bunker.prototype.compile = function () {
});
};
-Bunker.prototype.run = function (context) {
+Bunker.prototype.assign = function (context) {
if (!context) context = {};
var self = this;
var stack = [];
- var src = self.compile();
context[self.names.call] = function (i) {
var node = self.nodes[i];
@@ -91,7 +90,12 @@ Bunker.prototype.run = function (context) {
self.emit('node', node, stack);
};
- vm.runInNewContext(src, context);
+ return context;
+};
- return self;
+Bunker.prototype.run = function (context) {
+ var src = this.compile();
+ vm.runInNewContext(src, this.assign(context));
+
+ return this;
};
View
2  package.json
@@ -1,6 +1,6 @@
{
"name" : "bunker",
- "version" : "0.1.0",
+ "version" : "0.1.1",
"description" : "code coverage in native javascript",
"main" : "index.js",
"directories" : {
Please sign in to comment.
Something went wrong with that request. Please try again.