simplfy function name inference wrapper - closes #1002

This commit is contained in:
Sebastian McKenzie
2015-04-02 02:37:00 +11:00
parent f88a4147a6
commit cfff7aa6fb
7 changed files with 49 additions and 50 deletions

View File

@@ -25,13 +25,12 @@ var wrap = function (state, method, id, scope) {
var template = util.template(templateName, {
FUNCTION: method,
FUNCTION_ID: id,
FUNCTION_KEY: scope.generateUidIdentifier(id.name),
WRAPPER_KEY: scope.generateUidIdentifier(id.name + "Wrapper")
FUNCTION_KEY: scope.generateUidIdentifier(id.name)
});
// shim in dummy params to retain function arity, if you try to read the
// source then you'll get the original since it's proxied so it's all good
var params = template.callee.body.body[0].declarations[0].init.params;
var params = template.callee.body.body[0].params;
for (var i = 0, len = getFunctionArity(method); i < len; i++) {
params.push(scope.generateUidIdentifier("x"));
}

View File

@@ -1,11 +1,11 @@
(function (FUNCTION_KEY) {
var WRAPPER_KEY = function* FUNCTION_ID() {
return yield* FUNCTION_KEY.apply(this, arguments);
function* FUNCTION_ID() {
return yield* FUNCTION_ID.apply(this, arguments);
}
FUNCTION_ID.toString = function () {
return FUNCTION_ID.toString();
};
WRAPPER_KEY.toString = function () {
return FUNCTION_KEY.toString();
};
return WRAPPER_KEY;
return FUNCTION_ID;
})(FUNCTION)

View File

@@ -1,11 +1,11 @@
(function (FUNCTION_KEY) {
var WRAPPER_KEY = function FUNCTION_ID() {
function FUNCTION_ID() {
return FUNCTION_KEY.apply(this, arguments);
};
}
WRAPPER_KEY.toString = function () {
return FUNCTION_KEY.toString();
};
FUNCTION_ID.toString = function () {
return FUNCTION_ID.toString();
}
return WRAPPER_KEY;
return FUNCTION_ID;
})(FUNCTION)