Skip to content
Browse files

Allow arguments in functions

  • Loading branch information...
1 parent 60760f9 commit 3e319d760cb2f13fcaed096d6af8ce7e9c39dbed @creationix committed
Showing with 4 additions and 3 deletions.
  1. +4 −3 grain.js
View
7 grain.js
@@ -31,9 +31,9 @@ function compile(locals, callback) {
}
}
}
- function execute(position, fn) {
+ function execute(position, args, fn) {
try {
- chunks[position] = fn(function (err, result) {
+ args.push(function (err, result) {
if (err) {
if (stream) stream.emit('error', err);
if (callback) callback(err);
@@ -42,6 +42,7 @@ function compile(locals, callback) {
chunks[position] = result;
check();
});
+ chunks[position] = fn.apply(null, args);
} catch (err) {
if (stream) stream.emit('error', err);
if (callback) callback(err);
@@ -52,7 +53,7 @@ function compile(locals, callback) {
with(locals) {
// INSERT GENERATED CODE HERE
}
- });
+ }.bind(locals));
}
// Prepare variables for quick code replacement

0 comments on commit 3e319d7

Please sign in to comment.
Something went wrong with that request. Please try again.