simplfy function name inference wrapper - closes #1002
This commit is contained in:
parent
f88a4147a6
commit
cfff7aa6fb
@ -25,13 +25,12 @@ var wrap = function (state, method, id, scope) {
|
|||||||
var template = util.template(templateName, {
|
var template = util.template(templateName, {
|
||||||
FUNCTION: method,
|
FUNCTION: method,
|
||||||
FUNCTION_ID: id,
|
FUNCTION_ID: id,
|
||||||
FUNCTION_KEY: scope.generateUidIdentifier(id.name),
|
FUNCTION_KEY: scope.generateUidIdentifier(id.name)
|
||||||
WRAPPER_KEY: scope.generateUidIdentifier(id.name + "Wrapper")
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// shim in dummy params to retain function arity, if you try to read the
|
// 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
|
// 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++) {
|
for (var i = 0, len = getFunctionArity(method); i < len; i++) {
|
||||||
params.push(scope.generateUidIdentifier("x"));
|
params.push(scope.generateUidIdentifier("x"));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
(function (FUNCTION_KEY) {
|
(function (FUNCTION_KEY) {
|
||||||
var WRAPPER_KEY = function* FUNCTION_ID() {
|
function* FUNCTION_ID() {
|
||||||
return yield* FUNCTION_KEY.apply(this, arguments);
|
return yield* FUNCTION_ID.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUNCTION_ID.toString = function () {
|
||||||
|
return FUNCTION_ID.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
WRAPPER_KEY.toString = function () {
|
return FUNCTION_ID;
|
||||||
return FUNCTION_KEY.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return WRAPPER_KEY;
|
|
||||||
})(FUNCTION)
|
})(FUNCTION)
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
(function (FUNCTION_KEY) {
|
(function (FUNCTION_KEY) {
|
||||||
var WRAPPER_KEY = function FUNCTION_ID() {
|
function FUNCTION_ID() {
|
||||||
return FUNCTION_KEY.apply(this, arguments);
|
return FUNCTION_KEY.apply(this, arguments);
|
||||||
};
|
}
|
||||||
|
|
||||||
WRAPPER_KEY.toString = function () {
|
FUNCTION_ID.toString = function () {
|
||||||
return FUNCTION_KEY.toString();
|
return FUNCTION_ID.toString();
|
||||||
};
|
}
|
||||||
|
|
||||||
return WRAPPER_KEY;
|
return FUNCTION_ID;
|
||||||
})(FUNCTION)
|
})(FUNCTION)
|
||||||
|
|||||||
@ -1,15 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var i = (function (_i) {
|
var i = (function (_i) {
|
||||||
var _iWrapper = function i() {
|
function i() {
|
||||||
return _i.apply(this, arguments);
|
return _i.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
i.toString = function () {
|
||||||
|
return i.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
_iWrapper.toString = function () {
|
return i;
|
||||||
return _i.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return _iWrapper;
|
|
||||||
})(function () {
|
})(function () {
|
||||||
i = 5;
|
i = 5;
|
||||||
});
|
});
|
||||||
|
|||||||
@ -8,15 +8,15 @@ var obj = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
h: (function (_h) {
|
h: (function (_h) {
|
||||||
var _hWrapper = function h() {
|
function h() {
|
||||||
return _h.apply(this, arguments);
|
return _h.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
h.toString = function () {
|
||||||
|
return h.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
_hWrapper.toString = function () {
|
return h;
|
||||||
return _h.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return _hWrapper;
|
|
||||||
})(function () {
|
})(function () {
|
||||||
console.log(h);
|
console.log(h);
|
||||||
}),
|
}),
|
||||||
|
|||||||
@ -5,27 +5,27 @@ var f = function f() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var f = (function (_f) {
|
var f = (function (_f) {
|
||||||
var _fWrapper = function f(_x) {
|
function f(_x) {
|
||||||
return _f.apply(this, arguments);
|
return _f.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
f.toString = function () {
|
||||||
|
return f.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
_fWrapper.toString = function () {
|
return f;
|
||||||
return _f.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return _fWrapper;
|
|
||||||
})(function (f) {});
|
})(function (f) {});
|
||||||
|
|
||||||
var obj = {
|
var obj = {
|
||||||
f: (function (_f) {
|
f: (function (_f) {
|
||||||
var _fWrapper = function f(_x) {
|
function f(_x) {
|
||||||
return _f.apply(this, arguments);
|
return _f.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
f.toString = function () {
|
||||||
|
return f.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
_fWrapper.toString = function () {
|
return f;
|
||||||
return _f.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return _fWrapper;
|
|
||||||
})(function (f) {})
|
})(function (f) {})
|
||||||
};
|
};
|
||||||
@ -1,15 +1,15 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var f = (function (_f) {
|
var f = (function (_f) {
|
||||||
var _fWrapper = function f() {
|
function f() {
|
||||||
return _f.apply(this, arguments);
|
return _f.apply(this, arguments);
|
||||||
|
}
|
||||||
|
|
||||||
|
f.toString = function () {
|
||||||
|
return f.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
_fWrapper.toString = function () {
|
return f;
|
||||||
return _f.toString();
|
|
||||||
};
|
|
||||||
|
|
||||||
return _fWrapper;
|
|
||||||
})(function () {
|
})(function () {
|
||||||
console.log(f, g);
|
console.log(f, g);
|
||||||
});
|
});
|
||||||
Loading…
x
Reference in New Issue
Block a user