Comparing version 0.1.2 to 0.1.3
@@ -5,3 +5,4 @@ var vm = require('vm'); | ||
var wrapAsyncFunctions = require('./wrap-async-functions') | ||
var wrapAsyncFunctions = require('./wrap-async-functions'); | ||
var wrapError = require('./wrap-error'); | ||
@@ -52,2 +53,3 @@ module.exports = function asyncEval(code, options, callback) { | ||
} catch (err) { | ||
err = wrapError(err); | ||
sandbox._error = err; | ||
@@ -54,0 +56,0 @@ done(err); |
var _ = require('underscore')._; | ||
var wrapError = require('./wrap-error'); | ||
@@ -21,2 +22,3 @@ function wrapAsyncFunctions(asyncFunctions, sandbox, events, done, sandboxRoot) { | ||
} catch (err) { | ||
err = wrapError(err); | ||
sandbox._error = err; | ||
@@ -23,0 +25,0 @@ done(err); |
@@ -5,3 +5,3 @@ { | ||
"description": "Execute arbitrary JS with callbacks", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -59,2 +59,11 @@ var asyncEval = require('../'); | ||
it('should return a valid runtime error', function(done) { | ||
asyncEval("var x = undefined; \n x.toString();", function(err) { | ||
expect(err).to.exist; | ||
expect(err instanceof TypeError).to.equal(true); | ||
expect(err.message).to.equal("Cannot call method 'toString' of undefined"); | ||
done(); | ||
}); | ||
}); | ||
it('should not continue the event after cancel is called', function(done) { | ||
@@ -101,2 +110,19 @@ var test = function() { | ||
it('should return a valid runtime error from a callback', function(done) { | ||
var test = function() { | ||
var foo = undefined; | ||
wait(function() { | ||
foo.toString(); | ||
}); | ||
}; | ||
asyncEval(funcToString(test), {asyncFunctions: {wait: wait}}, function(err) { | ||
expect(err).to.exist; | ||
expect(err instanceof TypeError).to.equal(true); | ||
expect(err.message).to.equal("Cannot call method 'toString' of undefined"); | ||
done(); | ||
}); | ||
}); | ||
it('should support namespaced async functions', function(done) { | ||
@@ -103,0 +129,0 @@ |
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
9347
8
213
1