dry up array comprehension and arrow functions by introducing an alias-functions transformer

This commit is contained in:
Sebastian McKenzie
2014-10-13 05:35:26 +11:00
parent a6ffde6e9b
commit 3d2c41bb5a
10 changed files with 132 additions and 81 deletions

View File

@@ -1,6 +1,6 @@
function add() {
var _arguments = arguments;
return [1, 2, 3].map(function () {
return [1, 2, 3].map(function (i) {
return i * _arguments[0];
});
}

View File

@@ -1,6 +1,6 @@
function add() {
var _this = this;
return [1, 2, 3].map(function () {
return [1, 2, 3].map(function (i) {
return i * _this.multiplier;
});
}

View File

@@ -32,3 +32,14 @@ function five(obj) {
return fn();
}
five({ arguments: ["foo"] });
function six(obj) {
var fn = () => {
var fn2 = function () {
return arguments[0];
};
return fn2("foobar");
};
return fn();
}
six();

View File

@@ -43,3 +43,14 @@ function five(obj) {
return fn();
}
five({ arguments: ["foo"] });
function six(obj) {
var fn = function () {
var fn2 = function () {
return arguments[0];
};
return fn2("foobar");
};
return fn();
}
six();

View File

@@ -1,3 +1,4 @@
var _this = this;
var t = function (x) {
return this.x + x;
}.bind(this);
return _this.x + x;
};