Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a813341433 | ||
|
|
4968de9803 | ||
|
|
0de2d33e8d | ||
|
|
6f81ddd0d5 | ||
|
|
6b83055b12 | ||
|
|
080c23d5ed | ||
|
|
293bec58d7 | ||
|
|
93ceafc732 | ||
|
|
b2bac04b72 | ||
|
|
e549c37ca1 | ||
|
|
02512da38d | ||
|
|
abe9c4fd30 | ||
|
|
af21c52cc6 | ||
|
|
706626f79a | ||
|
|
c7a02ca289 |
11
CHANGELOG.md
11
CHANGELOG.md
@@ -2,6 +2,17 @@
|
||||
|
||||
Gaps between patch versions are faulty/broken releases.
|
||||
|
||||
## 2.4.2
|
||||
|
||||
* Upgrade `acorn-6to5`.
|
||||
* Better uids generated for various transformers based on parent node.
|
||||
* Alias flat references in `coreAliasing` transformer.
|
||||
|
||||
## 2.4.1
|
||||
|
||||
* Better whitespace handling of parenthesized expressions due to trailing comments.
|
||||
* Fix `yield` inside of comprehensions.
|
||||
|
||||
## 2.4.0
|
||||
|
||||
* Use a closure always for classes with a super.
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014 Sebastian McKenzie
|
||||
Copyright (c) 2014-2015 Sebastian McKenzie
|
||||
|
||||
MIT License
|
||||
|
||||
|
||||
@@ -11,10 +11,6 @@
|
||||
<img alt="Travis Status" src="http://img.shields.io/travis/6to5/6to5/master.svg?style=flat&label=travis">
|
||||
</a>
|
||||
|
||||
<a href="https://ci.appveyor.com/project/sebmck/6to5">
|
||||
<img alt="Appveyor Status" src="http://img.shields.io/appveyor/ci/sebmck/6to5.svg?style=flat&label=appveyor">
|
||||
</a>
|
||||
|
||||
<a href="https://codeclimate.com/github/6to5/6to5">
|
||||
<img alt="Code Climate Score" src="http://img.shields.io/codeclimate/github/6to5/6to5.svg?style=flat">
|
||||
</a>
|
||||
|
||||
@@ -90,23 +90,27 @@ equivalent to
|
||||
```javascript
|
||||
var foo = {
|
||||
get bar() {
|
||||
if (this._barRan) return this._bar;
|
||||
this._barRan = true;
|
||||
return this._bar = complex();
|
||||
return Object.defineProperty(this, "bar", {
|
||||
value: complex(),
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
}).bar;
|
||||
}
|
||||
};
|
||||
|
||||
class Foo {
|
||||
get bar() {
|
||||
if (this._barRan) return this._bar;
|
||||
this._barRan = true;
|
||||
return this._bar = complex();
|
||||
return Object.defineProperty(this, "bar", {
|
||||
value: complex(),
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true
|
||||
}).bar;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**NOTE:** Memoised functions will return the result of the **first** execution, regardless of arguments.
|
||||
|
||||
### This shorthand
|
||||
|
||||
```javascript
|
||||
|
||||
@@ -148,10 +148,11 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
};
|
||||
|
||||
if (this[node.type]) {
|
||||
// only compute if this node needs parens if our parent has been changed
|
||||
// since acorn would've wrapped us in a ParanthesizedExpression
|
||||
var needsParens = n.needsParens(node, parent);
|
||||
var needsCommentParens = t.isExpression(node) && node.leadingComments && node.leadingComments.length;
|
||||
var needsParens = needsCommentParens || n.needsParens(node, parent);
|
||||
|
||||
if (needsParens) this.push("(");
|
||||
if (needsCommentParens) this.indent();
|
||||
|
||||
this.printLeadingComments(node, parent);
|
||||
|
||||
@@ -162,6 +163,10 @@ CodeGenerator.prototype.print = function (node, parent, opts) {
|
||||
|
||||
this[node.type](node, this.buildPrint(node), parent);
|
||||
|
||||
if (needsCommentParens) {
|
||||
this.newline();
|
||||
this.dedent();
|
||||
}
|
||||
if (needsParens) this.push(")");
|
||||
|
||||
this.map.mark(node, "end");
|
||||
|
||||
@@ -60,10 +60,6 @@ Node.prototype.needsParens = function () {
|
||||
|
||||
if (!parent) return false;
|
||||
|
||||
if (t.isExpression(node) && node.leadingComments && node.leadingComments.length) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (t.isNewExpression(parent) && parent.callee === node) {
|
||||
return t.isCallExpression(node) || _.some(node, function (val) {
|
||||
return t.isCallExpression(val);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.Property = function (node) {
|
||||
if (node.method) node.method = false;
|
||||
@@ -21,7 +22,7 @@ exports.ObjectExpression = function (node, parent, file) {
|
||||
if (!hasAny) return;
|
||||
|
||||
if (node.properties.length) {
|
||||
var objId = util.getUid(parent, file);
|
||||
var objId = t.getUid(parent, file);
|
||||
|
||||
return util.template("object-define-properties-closure", {
|
||||
KEY: objId,
|
||||
|
||||
@@ -87,11 +87,9 @@ Class.prototype.run = function () {
|
||||
|
||||
if (superName) {
|
||||
this.closure = true;
|
||||
// so we're only evaluating it once
|
||||
var superRefName = "super";
|
||||
if (className) superRefName = className.name + "Super";
|
||||
|
||||
var superRef = file.generateUidIdentifier(superRefName, this.scope);
|
||||
// so we're only evaluating it once
|
||||
var superRef = t.getUid(superName, this.file);
|
||||
body.unshift(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(superRef, superName)
|
||||
]));
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
var util = require("../../util");
|
||||
var t = require("../../types");
|
||||
var t = require("../../types");
|
||||
|
||||
exports.ObjectExpression = function (node, parent, file) {
|
||||
var hasComputed = false;
|
||||
@@ -14,7 +13,7 @@ exports.ObjectExpression = function (node, parent, file) {
|
||||
|
||||
if (!hasComputed) return;
|
||||
|
||||
var objId = util.getUid(parent, file);
|
||||
var objId = t.getUid(parent, file);
|
||||
|
||||
var body = [];
|
||||
var container = t.functionExpression(null, [], t.blockStatement(body));
|
||||
|
||||
@@ -75,7 +75,7 @@ var pushArrayPattern = function (opts, nodes, pattern, parentId) {
|
||||
|
||||
var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length);
|
||||
|
||||
var _parentId = opts.file.generateUidIdentifier("ref", opts.scope);
|
||||
var _parentId = t.getUid(parentId, opts.file, opts.scope);
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(_parentId, toArray)
|
||||
]));
|
||||
@@ -113,7 +113,7 @@ var pushPattern = function (opts) {
|
||||
var scope = opts.scope;
|
||||
|
||||
if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
|
||||
var key = file.generateUidIdentifier("ref", scope);
|
||||
var key = t.getUid(parentId, file, scope);
|
||||
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(key, parentId)
|
||||
|
||||
@@ -4,8 +4,8 @@ var t = require("../../types");
|
||||
|
||||
exports.experimental = true;
|
||||
|
||||
var build = function (node, file) {
|
||||
var uid = file.generateUidIdentifier("arr");
|
||||
var build = function (node, parent, file, scope) {
|
||||
var uid = t.getUid(parent, file, scope);
|
||||
|
||||
var container = util.template("array-comprehension-container", {
|
||||
KEY: uid
|
||||
@@ -16,7 +16,7 @@ var build = function (node, file) {
|
||||
var body = block.body;
|
||||
|
||||
if (traverse.hasType(node, "YieldExpression", t.FUNCTION_TYPES)) {
|
||||
container.generator = true;
|
||||
container.callee.generator = true;
|
||||
container = t.yieldExpression(container, true);
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ exports._build = function (node, buildBody) {
|
||||
);
|
||||
};
|
||||
|
||||
exports.ComprehensionExpression = function (node, parent, file) {
|
||||
exports.ComprehensionExpression = function (node, parent, file, scope) {
|
||||
if (node.generator) return;
|
||||
|
||||
return build(node, file);
|
||||
return build(node, parent, file, scope);
|
||||
};
|
||||
|
||||
@@ -4,6 +4,10 @@ var core = require("core-js/library");
|
||||
var t = require("../../types");
|
||||
var _ = require("lodash");
|
||||
|
||||
var coreHas = function (node) {
|
||||
return node.name !== "_" && _.has(core, node.name);
|
||||
};
|
||||
|
||||
exports.optional = true;
|
||||
|
||||
exports.ast = {
|
||||
@@ -24,11 +28,13 @@ exports.ast = {
|
||||
|
||||
if (!t.isReferenced(obj, node)) return;
|
||||
|
||||
var coreHasObject = obj.name !== "_" && _.has(core, obj.name);
|
||||
if (coreHasObject && _.has(core[obj.name], prop.name)) {
|
||||
if (coreHas(obj) && _.has(core[obj.name], prop.name)) {
|
||||
this.stop();
|
||||
return t.memberExpression(file._coreId, node);
|
||||
}
|
||||
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && coreHas(node)) {
|
||||
// new Promise -> new _core.Promise
|
||||
return t.memberExpression(file._coreId, node);
|
||||
} else if (t.isCallExpression(node)) {
|
||||
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ var getPropRef = function (nodes, prop, file, scope) {
|
||||
if (t.isIdentifier(prop)) {
|
||||
return t.literal(prop.name);
|
||||
} else {
|
||||
var temp = file.generateUidIdentifier("propKey", scope);
|
||||
var temp = t.getUid(prop, file, scope);
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(temp, prop)
|
||||
]));
|
||||
@@ -20,7 +20,7 @@ var getPropRef = function (nodes, prop, file, scope) {
|
||||
|
||||
var getObjRef = function (nodes, obj, file, scope) {
|
||||
if (t.isDynamic(obj)) {
|
||||
var temp = file.generateUidIdentifier("obj", scope);
|
||||
var temp = t.getUid(obj, file, scope);
|
||||
nodes.push(t.variableDeclaration("var", [
|
||||
t.variableDeclarator(temp, obj)
|
||||
]));
|
||||
|
||||
@@ -156,7 +156,7 @@ t.toIdentifier = function (name) {
|
||||
if (t.isIdentifier(name)) return name.name;
|
||||
|
||||
// replace all non-valid identifiers with dashes
|
||||
name = name.replace(/[^a-zA-Z0-9]/g, "-");
|
||||
name = name.replace(/[^a-zA-Z0-9$_]/g, "-");
|
||||
|
||||
// remove all dashes and numbers from start of name
|
||||
name = name.replace(/^[-0-9]+/, "");
|
||||
@@ -166,6 +166,9 @@ t.toIdentifier = function (name) {
|
||||
return c ? c.toUpperCase() : "";
|
||||
});
|
||||
|
||||
// remove underscores from start of name
|
||||
name = name.replace(/^\_/, "");
|
||||
|
||||
return name || '_';
|
||||
};
|
||||
|
||||
@@ -231,6 +234,49 @@ t.toBlock = function (node, parent) {
|
||||
return t.blockStatement(node);
|
||||
};
|
||||
|
||||
t.getUid = function (parent, file, scope) {
|
||||
var node = parent;
|
||||
|
||||
if (t.isAssignmentExpression(parent)) {
|
||||
node = parent.left;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
node = parent.id;
|
||||
}
|
||||
|
||||
var id = "ref";
|
||||
|
||||
if (t.isProperty(node)) {
|
||||
node = node.key;
|
||||
}
|
||||
|
||||
if (t.isIdentifier(node)) {
|
||||
id = node.name;
|
||||
} else if (t.isLiteral(node)) {
|
||||
id = node.value;
|
||||
} else if (t.isMemberExpression(node)) {
|
||||
var parts = [];
|
||||
|
||||
var add = function (node) {
|
||||
if (t.isMemberExpression(node)) {
|
||||
add(node.object);
|
||||
add(node.property);
|
||||
} else if (t.isIdentifier(node)) {
|
||||
parts.push(node.name);
|
||||
} else if (t.isLiteral(node)) {
|
||||
parts.push(node.value);
|
||||
}
|
||||
};
|
||||
|
||||
add(node);
|
||||
|
||||
id = parts.join("$");
|
||||
}
|
||||
|
||||
id = id.replace(/^_/, "");
|
||||
|
||||
return file.generateUidIdentifier(id, scope);
|
||||
};
|
||||
|
||||
t.getIds = function (node, map, ignoreTypes) {
|
||||
ignoreTypes = ignoreTypes || [];
|
||||
|
||||
|
||||
@@ -52,22 +52,6 @@ exports.arrayify = function (val) {
|
||||
throw new TypeError("illegal type for arrayify");
|
||||
};
|
||||
|
||||
exports.getUid = function (parent, file) {
|
||||
var node;
|
||||
|
||||
if (t.isAssignmentExpression(parent)) {
|
||||
node = parent.left;
|
||||
} else if (t.isVariableDeclarator(parent)) {
|
||||
node = parent.id;
|
||||
}
|
||||
|
||||
var id = "ref";
|
||||
|
||||
if (t.isIdentifier(node)) id = node.name;
|
||||
|
||||
return file.generateUidIdentifier(id);
|
||||
};
|
||||
|
||||
exports.isAbsolute = function (loc) {
|
||||
if (!loc) return false;
|
||||
if (loc[0] === "/") return true; // unix
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "6to5",
|
||||
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.2",
|
||||
"author": "Sebastian McKenzie <sebmck@gmail.com>",
|
||||
"homepage": "https://github.com/6to5/6to5",
|
||||
"repository": {
|
||||
@@ -35,7 +35,7 @@
|
||||
"test": "make test"
|
||||
},
|
||||
"dependencies": {
|
||||
"acorn-6to5": "0.11.1-1",
|
||||
"acorn-6to5": "0.11.1-2",
|
||||
"ast-types": "~0.6.1",
|
||||
"chokidar": "0.11.1",
|
||||
"commander": "2.5.0",
|
||||
|
||||
@@ -6,5 +6,6 @@ var test = {
|
||||
[( /*
|
||||
* Inside bracket init
|
||||
*/
|
||||
"b")]: "2"
|
||||
"b"
|
||||
)]: "2"
|
||||
}, ok = 42;
|
||||
|
||||
@@ -7,7 +7,8 @@ var test = {
|
||||
[( /*
|
||||
* Inside bracket init
|
||||
*/
|
||||
"b")]: "2",
|
||||
"b"
|
||||
)]: "2",
|
||||
|
||||
["c"
|
||||
/*
|
||||
@@ -18,8 +19,9 @@ var test = {
|
||||
["d"]: "4",
|
||||
|
||||
[(
|
||||
// Inside bracket, line comment
|
||||
"e")]: "5",
|
||||
// Inside bracket, line comment
|
||||
"e"
|
||||
)]: "5",
|
||||
|
||||
["f"
|
||||
// After bracket, line comment
|
||||
|
||||
@@ -14,32 +14,32 @@ var _inherits = function (child, parent) {
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _TestSuper = Foo;
|
||||
var _Foo = Foo;
|
||||
var Test = function Test() {
|
||||
woops["super"].test();
|
||||
_TestSuper.call(this);
|
||||
_TestSuper.prototype.test.call(this);
|
||||
foob(_TestSuper);
|
||||
_Foo.call(this);
|
||||
_Foo.prototype.test.call(this);
|
||||
foob(_Foo);
|
||||
|
||||
_TestSuper.call.apply(_TestSuper, [this].concat(_slice.call(arguments)));
|
||||
_TestSuper.call.apply(_TestSuper, [this, "test"].concat(_slice.call(arguments)));
|
||||
_Foo.call.apply(_Foo, [this].concat(_slice.call(arguments)));
|
||||
_Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
|
||||
_TestSuper.prototype.test.call.apply(_TestSuper.prototype, [this].concat(_slice.call(arguments)));
|
||||
_TestSuper.prototype.test.call.apply(_TestSuper.prototype, [this, "test"].concat(_slice.call(arguments)));
|
||||
_Foo.prototype.test.call.apply(_Foo.prototype, [this].concat(_slice.call(arguments)));
|
||||
_Foo.prototype.test.call.apply(_Foo.prototype, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
_inherits(Test, _TestSuper);
|
||||
_inherits(Test, _Foo);
|
||||
|
||||
Test.prototype.test = function () {
|
||||
_TestSuper.prototype.test.call(this);
|
||||
_TestSuper.prototype.test.call.apply(_TestSuper.prototype.test, [this].concat(_slice.call(arguments)));
|
||||
_TestSuper.prototype.test.call.apply(_TestSuper.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
||||
_Foo.prototype.test.call(this);
|
||||
_Foo.prototype.test.call.apply(_Foo.prototype.test, [this].concat(_slice.call(arguments)));
|
||||
_Foo.prototype.test.call.apply(_Foo.prototype.test, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
Test.foo = function () {
|
||||
_TestSuper.foo.call(this);
|
||||
_TestSuper.foo.call.apply(_TestSuper.foo, [this].concat(_slice.call(arguments)));
|
||||
_TestSuper.foo.call.apply(_TestSuper.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
_Foo.foo.call(this);
|
||||
_Foo.foo.call.apply(_Foo.foo, [this].concat(_slice.call(arguments)));
|
||||
_Foo.foo.call.apply(_Foo.foo, [this, "test"].concat(_slice.call(arguments)));
|
||||
};
|
||||
|
||||
return Test;
|
||||
|
||||
@@ -13,13 +13,13 @@ var _inherits = function (child, parent) {
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _TestSuper = Foo;
|
||||
var _Foo = Foo;
|
||||
var Test = function Test() {
|
||||
_TestSuper.prototype.test;
|
||||
_TestSuper.prototype.test.whatever;
|
||||
_Foo.prototype.test;
|
||||
_Foo.prototype.test.whatever;
|
||||
};
|
||||
|
||||
_inherits(Test, _TestSuper);
|
||||
_inherits(Test, _Foo);
|
||||
|
||||
return Test;
|
||||
})();
|
||||
|
||||
@@ -13,16 +13,16 @@ var _inherits = function (child, parent) {
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _TestSuper = Foo;
|
||||
var _Foo = Foo;
|
||||
var Test = function Test() {
|
||||
_TestSuper.prototype.test.whatever();
|
||||
_TestSuper.prototype.test.call(this);
|
||||
_Foo.prototype.test.whatever();
|
||||
_Foo.prototype.test.call(this);
|
||||
};
|
||||
|
||||
_inherits(Test, _TestSuper);
|
||||
_inherits(Test, _Foo);
|
||||
|
||||
Test.test = function () {
|
||||
return _TestSuper.wow.call(this);
|
||||
return _Foo.wow.call(this);
|
||||
};
|
||||
|
||||
return Test;
|
||||
|
||||
@@ -17,12 +17,12 @@ var Test = function Test() {
|
||||
};
|
||||
|
||||
var Foo = (function () {
|
||||
var _FooSuper = Bar;
|
||||
var _Bar = Bar;
|
||||
var Foo = function Foo() {
|
||||
this.state = "test";
|
||||
};
|
||||
|
||||
_inherits(Foo, _FooSuper);
|
||||
_inherits(Foo, _Bar);
|
||||
|
||||
return Foo;
|
||||
})();
|
||||
|
||||
@@ -13,27 +13,27 @@ var _inherits = function (child, parent) {
|
||||
};
|
||||
|
||||
var BaseController = (function () {
|
||||
var _BaseControllerSuper = Chaplin.Controller;
|
||||
var _Chaplin$Controller = Chaplin.Controller;
|
||||
var BaseController = function BaseController() {
|
||||
if (_BaseControllerSuper) {
|
||||
_BaseControllerSuper.apply(this, arguments);
|
||||
if (_Chaplin$Controller) {
|
||||
_Chaplin$Controller.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(BaseController, _BaseControllerSuper);
|
||||
_inherits(BaseController, _Chaplin$Controller);
|
||||
|
||||
return BaseController;
|
||||
})();
|
||||
|
||||
var BaseController2 = (function () {
|
||||
var _BaseController2Super = Chaplin.Controller.Another;
|
||||
var _Chaplin$Controller$Another = Chaplin.Controller.Another;
|
||||
var BaseController2 = function BaseController2() {
|
||||
if (_BaseController2Super) {
|
||||
_BaseController2Super.apply(this, arguments);
|
||||
if (_Chaplin$Controller$Another) {
|
||||
_Chaplin$Controller$Another.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(BaseController2, _BaseController2Super);
|
||||
_inherits(BaseController2, _Chaplin$Controller$Another);
|
||||
|
||||
return BaseController2;
|
||||
})();
|
||||
|
||||
@@ -13,14 +13,14 @@ var _inherits = function (child, parent) {
|
||||
};
|
||||
|
||||
var Test = (function () {
|
||||
var _TestSuper = Foo;
|
||||
var _Foo = Foo;
|
||||
var Test = function Test() {
|
||||
if (_TestSuper) {
|
||||
_TestSuper.apply(this, arguments);
|
||||
if (_Foo) {
|
||||
_Foo.apply(this, arguments);
|
||||
}
|
||||
};
|
||||
|
||||
_inherits(Test, _TestSuper);
|
||||
_inherits(Test, _Foo);
|
||||
|
||||
return Test;
|
||||
})();
|
||||
|
||||
@@ -24,15 +24,15 @@ var a = _ref2[0];
|
||||
var b = _ref2[1];
|
||||
var _ref3 = [3, 4];
|
||||
|
||||
var _ref4 = _slicedToArray(_ref3, 2);
|
||||
var _ref3 = _slicedToArray(_ref3, 2);
|
||||
|
||||
var c = _ref4[0];
|
||||
var d = _ref4[1];
|
||||
var _ref5 = { e: 5, f: 6 };
|
||||
var c = _ref3[0];
|
||||
var d = _ref3[1];
|
||||
var _ref4 = { e: 5, f: 6 };
|
||||
|
||||
var e = _ref5.e;
|
||||
var f = _ref5.f;
|
||||
var _ref6 = { a: 7, b: 8 };
|
||||
var e = _ref4.e;
|
||||
var f = _ref4.f;
|
||||
var _ref5 = { a: 7, b: 8 };
|
||||
|
||||
var g = _ref6.a;
|
||||
var h = _ref6.b;
|
||||
var g = _ref5.a;
|
||||
var h = _ref5.b;
|
||||
|
||||
@@ -21,10 +21,10 @@ var _ref = ["hello", [", ", "junk"], ["world"]];
|
||||
var _ref2 = _slicedToArray(_ref, 4);
|
||||
|
||||
var a = _ref2[0];
|
||||
var _ref3 = _slicedToArray(_ref2[1], 1);
|
||||
var _ref2$1 = _slicedToArray(_ref2[1], 1);
|
||||
|
||||
var b = _ref3[0];
|
||||
var _ref4 = _slicedToArray(_ref2[2], 1);
|
||||
var b = _ref2$1[0];
|
||||
var _ref2$2 = _slicedToArray(_ref2[2], 1);
|
||||
|
||||
var c = _ref4[0];
|
||||
var c = _ref2$2[0];
|
||||
var d = _ref2[3];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _temp, _ref;
|
||||
var _temp, _temp2;
|
||||
var _slicedToArray = function (arr, i) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
@@ -17,4 +17,4 @@ var _slicedToArray = function (arr, i) {
|
||||
}
|
||||
};
|
||||
|
||||
console.log((_temp = [123], _ref = _slicedToArray(_temp, 1), x = _ref[0], _temp));
|
||||
console.log((_temp = [123], _temp2 = _slicedToArray(_temp, 1), x = _temp2[0], _temp));
|
||||
|
||||
@@ -21,10 +21,10 @@ var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
|
||||
var _ref2 = _slicedToArray(_ref, 5);
|
||||
|
||||
var a = _ref2[1];
|
||||
var _ref3 = _slicedToArray(_ref2[2], 1);
|
||||
var _ref2$2 = _slicedToArray(_ref2[2], 1);
|
||||
|
||||
var b = _ref3[0];
|
||||
var _ref4 = _slicedToArray(_ref2[3], 1);
|
||||
var b = _ref2$2[0];
|
||||
var _ref2$3 = _slicedToArray(_ref2[3], 1);
|
||||
|
||||
var c = _ref4[0];
|
||||
var c = _ref2$3[0];
|
||||
var d = _ref2[4];
|
||||
|
||||
@@ -16,11 +16,11 @@ var _slicedToArray = function (arr, i) {
|
||||
}
|
||||
};
|
||||
|
||||
var _ref = _slicedToArray(rect.topLeft, 2);
|
||||
var _rect$topLeft = _slicedToArray(rect.topLeft, 2);
|
||||
|
||||
var x1 = _ref[0];
|
||||
var y1 = _ref[1];
|
||||
var _ref2 = _slicedToArray(rect.bottomRight, 2);
|
||||
var x1 = _rect$topLeft[0];
|
||||
var y1 = _rect$topLeft[1];
|
||||
var _rect$bottomRight = _slicedToArray(rect.bottomRight, 2);
|
||||
|
||||
var x2 = _ref2[0];
|
||||
var y2 = _ref2[1];
|
||||
var x2 = _rect$bottomRight[0];
|
||||
var y2 = _rect$bottomRight[1];
|
||||
|
||||
@@ -31,17 +31,17 @@ function unpackObject(_ref2) {
|
||||
|
||||
console.log(unpackObject({ title: "title", author: "author" }));
|
||||
|
||||
var unpackArray = function (_ref3, _ref5) {
|
||||
var _ref4 = _slicedToArray(_ref3, 3);
|
||||
var unpackArray = function (_ref3, _ref4) {
|
||||
var _ref3 = _slicedToArray(_ref3, 3);
|
||||
|
||||
var a = _ref4[0];
|
||||
var b = _ref4[1];
|
||||
var c = _ref4[2];
|
||||
var _ref6 = _slicedToArray(_ref5, 3);
|
||||
var a = _ref3[0];
|
||||
var b = _ref3[1];
|
||||
var c = _ref3[2];
|
||||
var _ref4 = _slicedToArray(_ref4, 3);
|
||||
|
||||
var x = _ref6[0];
|
||||
var y = _ref6[1];
|
||||
var z = _ref6[2];
|
||||
var x = _ref4[0];
|
||||
var y = _ref4[1];
|
||||
var z = _ref4[2];
|
||||
return a + b + c;
|
||||
};
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
function add() {
|
||||
var _arguments = arguments;
|
||||
return (function () {
|
||||
var _arr = [];
|
||||
var _ref = [];
|
||||
|
||||
for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
_arr.push(i * _arguments[0]);
|
||||
_ref.push(i * _arguments[0]);
|
||||
}
|
||||
|
||||
return _arr;
|
||||
return _ref;
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
var seattlers = (function () {
|
||||
var _arr = [];
|
||||
var _seattlers = [];
|
||||
|
||||
for (var _iterator = countries[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var customers = _step.value;
|
||||
for (var _iterator2 = customers[Symbol.iterator](), _step2; !(_step2 = _iterator2.next()).done;) {
|
||||
var c = _step2.value;
|
||||
if (c.city == "Seattle") {
|
||||
_arr.push({ name: c.name, age: c.age });
|
||||
_seattlers.push({ name: c.name, age: c.age });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
return _seattlers;
|
||||
})();
|
||||
|
||||
@@ -3,14 +3,14 @@
|
||||
function add() {
|
||||
var _this = this;
|
||||
return (function () {
|
||||
var _arr = [];
|
||||
var _ref = [];
|
||||
|
||||
for (var _iterator = [1, 2, 3][Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
|
||||
var i = _step.value;
|
||||
_arr.push(i * _this.multiplier);
|
||||
_ref.push(i * _this.multiplier);
|
||||
}
|
||||
|
||||
return _arr;
|
||||
return _ref;
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ var _ref = ["hello", [", ", "junk"], ["world"]];
|
||||
var _ref2 = _slicedToArray(_ref, 4);
|
||||
|
||||
var a = _ref2[0];
|
||||
var _ref3 = _slicedToArray(_ref2[1], 1);
|
||||
var _ref2$1 = _slicedToArray(_ref2[1], 1);
|
||||
|
||||
var b = _ref3[0];
|
||||
var _ref4 = _slicedToArray(_ref2[2], 1);
|
||||
var b = _ref2$1[0];
|
||||
var _ref2$2 = _slicedToArray(_ref2[2], 1);
|
||||
|
||||
var c = _ref4[0];
|
||||
var c = _ref2$2[0];
|
||||
var d = _ref2[3];
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
var _propKey2, _obj2, _propKey4;
|
||||
var _ref2, _obj2, _ref4;
|
||||
var _hasOwn = Object.prototype.hasOwnProperty;
|
||||
var obj = {};
|
||||
|
||||
@@ -9,17 +9,17 @@ if (!_hasOwn.call(obj, "x")) obj.x = 2;
|
||||
|
||||
console.log((!_hasOwn.call(obj, "x") && (obj.x = 2), obj.x));
|
||||
|
||||
var _propKey = x();
|
||||
var _ref = x();
|
||||
|
||||
if (!_hasOwn.call(obj, _propKey)) obj[_propKey] = 2;
|
||||
if (!_hasOwn.call(obj, _ref)) obj[_ref] = 2;
|
||||
|
||||
|
||||
console.log((_propKey2 = x(), !_hasOwn.call(obj, _propKey2) && (obj[_propKey2] = 2), obj[_propKey2]));
|
||||
console.log((_ref2 = x(), !_hasOwn.call(obj, _ref2) && (obj[_ref2] = 2), obj[_ref2]));
|
||||
|
||||
var _obj = obj[y()];
|
||||
var _propKey3 = x();
|
||||
var _ref3 = x();
|
||||
|
||||
if (!_hasOwn.call(_obj, _propKey3)) _obj[_propKey3] = 2;
|
||||
if (!_hasOwn.call(_obj, _ref3)) _obj[_ref3] = 2;
|
||||
|
||||
|
||||
console.log((_obj2 = obj[y()], _propKey4 = x(), !_hasOwn.call(_obj2, _propKey4) && (_obj2[_propKey4] = 2), _obj2[_propKey4]));
|
||||
console.log((_obj2 = obj[y()], _ref4 = x(), !_hasOwn.call(_obj2, _ref4) && (_obj2[_ref4] = 2), _obj2[_ref4]));
|
||||
|
||||
Reference in New Issue
Block a user