Compare commits

...

27 Commits

Author SHA1 Message Date
Sebastian McKenzie
781467d423 v2.1.0 2014-12-29 01:41:05 +11:00
Sebastian McKenzie
44f5b7d013 fix case statement newline in code generator test 2014-12-29 01:39:04 +11:00
Sebastian McKenzie
dcf7f0b70b fix newline in case statement test 2014-12-29 01:37:19 +11:00
Sebastian McKenzie
03efd69998 check if node exists before inheriting comments to it 2014-12-29 01:37:12 +11:00
Sebastian McKenzie
213003a007 fix new templates path in dotfiles 2014-12-29 01:34:49 +11:00
Sebastian McKenzie
b0503f2efe add 2.1.0 changelog 2014-12-29 01:33:58 +11:00
Sebastian McKenzie
c8cf7ff286 better blacklist tests and expose register cache - closes #344 2014-12-29 01:31:26 +11:00
Sebastian McKenzie
ceb32816d7 fix destructuring in switch/case statements - closes #346 2014-12-29 01:26:51 +11:00
Sebastian McKenzie
32b94899a6 update runtime script to runtime generator 2014-12-29 01:26:21 +11:00
Sebastian McKenzie
d951082b09 move replacement node comment inheritance to traverse replacement 2014-12-29 01:26:11 +11:00
Sebastian McKenzie
b49f6e33d6 fix newline on case statement 2014-12-29 01:25:56 +11:00
Sebastian McKenzie
c5fa6425a5 explicit canRun for hidden transformers 2014-12-29 01:25:15 +11:00
Sebastian McKenzie
70d896d609 rename runtime script to runtime-generator 2014-12-29 01:24:57 +11:00
Sebastian McKenzie
e00fa8c9b1 update core-js 2014-12-29 01:24:41 +11:00
Sebastian McKenzie
13933bc9b8 move templates folder into transformation folder 2014-12-29 01:24:35 +11:00
Sebastian McKenzie
005f5b2174 v2.0.4 2014-12-28 11:06:04 +11:00
Sebastian McKenzie
8551c94fa0 fix linting errors 2014-12-28 11:05:27 +11:00
Sebastian McKenzie
c509d06bc2 vaoid being greedy when destructuring array iterables 2014-12-28 11:04:00 +11:00
Sebastian McKenzie
f21743012b v2.0.3 2014-12-28 09:37:32 +11:00
Sebastian McKenzie
22dc33f93c remove unused variable 2014-12-28 09:36:29 +11:00
Sebastian McKenzie
6df6652629 better circular references in amd/umd/system module formatter 2014-12-28 09:35:47 +11:00
Sebastian McKenzie
4942ba6dd7 v2.0.2 2014-12-28 01:14:54 +11:00
Sebastian McKenzie
b63bd8cba0 remove interopRequire from system module formatter 2014-12-28 01:14:08 +11:00
Sebastian McKenzie
cd1eb11171 Merge branch 'master' of github.com:6to5/6to5 2014-12-28 01:10:00 +11:00
Sebastian McKenzie
6e1c12fd78 inherit comments in for-of transformer 2014-12-28 01:09:48 +11:00
Sebastian McKenzie
a4ea71b85d Merge pull request #337 from guybedford/master
Correct system format base support tests
2014-12-28 01:03:35 +11:00
guybedford
5c39685650 correct system format base support tests 2014-12-27 15:59:52 +02:00
80 changed files with 345 additions and 142 deletions

View File

@@ -1,3 +1,3 @@
node_modules
test
lib/6to5/templates
lib/6to5/transformation/templates

View File

@@ -1,7 +1,7 @@
node_modules
*.log
*.cache
lib/6to5/templates
lib/6to5/transformation/templates
test
benchmark
Makefile

View File

@@ -2,6 +2,27 @@
Gaps between patch versions are faulty/broken releases.
## 2.1.0
* Add `cache` option to register hook.
* Update `core-js`.
* Fix starting newline not being added on case statements.
* Fix destructuring `VariableDeclaration`s not inside `BlockStatement`s and `Program`.
## 2.0.4
* Avoid being greedy when destructuring array iterables.
## 2.0.3
* Hoist function declarations in system module formatter for circular references.
* Hoist default function declarations in umd and amd module formatters for circular references.
## 2.0.2
* Inherit comments in `for-of` transformer.
* Remove `interopRequire` from `system` module formatter.
## 2.0.1
* Remap `UpdateExpression` module export binding.

View File

@@ -1,4 +1,4 @@
#!/usr/bin/env node
var runtime = require("../lib/6to5/runtime");
var runtime = require("../lib/6to5/runtime-generator");
console.log(runtime(process.argv[2]));

View File

@@ -250,6 +250,10 @@ require("6to5/register")({
// This will remove the currently hooked extensions of .es6 and .js so you'll
// have to add them back if you want them to be used again.
extensions: [".js", ".es6"]
extensions: [".js", ".es6"],
// Enables `roadrunner` cache that will save to a `.roadrunner.json` file in your cwd
// Do not check this into git as it's user-specific
cache: true
});
```

View File

@@ -22,6 +22,7 @@ File.declarations = [
"tagged-template-literal",
"interop-require",
"to-array",
"sliced-to-array",
"object-without-properties",
"has-own",
"slice"
@@ -82,13 +83,19 @@ File.normaliseOptions = function (opts) {
return opts;
};
File.prototype.toArray = function (node) {
File.prototype.toArray = function (node, i) {
if (t.isArrayExpression(node)) {
return node;
} else if (t.isIdentifier(node) && node.name === "arguments") {
return t.callExpression(t.memberExpression(this.addDeclaration("slice"), t.identifier("call")), [node]);
} else {
return t.callExpression(this.addDeclaration("to-array"), [node]);
var declarationName = "to-array";
var args = [node];
if (i) {
args.push(t.literal(i));
declarationName = "sliced-to-array";
}
return t.callExpression(this.addDeclaration(declarationName), args);
}
};

View File

@@ -146,7 +146,7 @@ exports.SwitchCase = function (node, print) {
this.push("default:");
}
this.space();
this.newline();
print.sequence(node.consequent, { indent: true });
};

View File

@@ -7,7 +7,7 @@ exports.Transformer = require("./transformation/transformer");
exports.types = require("./types");
exports.runtime = require("./runtime");
exports.runtime = require("./runtime-generator");
exports.register = function (opts) {
var register = require("./register");

View File

@@ -1,6 +1,7 @@
require("./polyfill");
var sourceMapSupport = require("source-map-support");
var roadrunner = require("roadrunner");
var util = require("./util");
var to5 = require("./index");
var fs = require("fs");
@@ -38,15 +39,22 @@ var blacklistTest = function (transformer, code) {
};
blacklistTest("arrayComprehension", "var foo = [for (foo of bar) foo * foo];");
//blacklistTest("generatorComprehension", "");
blacklistTest("generatorComprehension", "var foo = (for (foo of bar) foo * foo)");
blacklistTest("arrowFunctions", "var foo = x => x * x;");
blacklistTest("classes", "class Foo {}");
blacklistTest("computedPropertyNames", "var foo = { [foo]: bar };");
//blacklistTest("constants", "const foo = 0;");
blacklistTest("constants", function () {
try {
new Function("const foo = 'foo';\nfoo = 'wow';");
} catch (err) {
return; // constants are supported
}
throw new SyntaxError;
});
blacklistTest("defaultParamaters", "var foo = function (bar = 0) {};");
blacklistTest("destructuring", "var { x, y } = { x: 0, y: 0 };");
blacklistTest("forOf", "for (var foo of bar) {}");
blacklistTest("generators", "function* foo() {}");
blacklistTest("generators", "function* foo() {}\nasync function bar() {}"); // generators/async functions delegated to same transformer
blacklistTest("letScoping", "let foo = 0;");
blacklistTest("modules", 'import foo from "from";');
blacklistTest("propertyMethodAssignment", "{ get foo() {} }");
@@ -130,6 +138,11 @@ module.exports = function (opts) {
if (opts.cache) cache = opts.cache;
if (opts.cache === false) cache = null;
if (opts.cache === true) {
roadrunner.load();
roadrunner.setup();
cache = roadrunner.get("6to5");
}
_.extend(transformOpts, opts);
};

View File

@@ -169,30 +169,36 @@ DefaultFormatter.prototype._exportsAssign = function (id, init) {
DefaultFormatter.prototype.exportDeclaration = function (node, nodes) {
var declar = node.declaration;
var id = declar.id;
if (node.default) {
nodes.push(
this._exportsAssign(t.identifier("default"), this._pushStatement(declar, nodes))
);
} else {
var assign;
id = t.identifier("default");
}
if (t.isVariableDeclaration(declar)) {
for (var i in declar.declarations) {
var decl = declar.declarations[i];
var assign;
decl.init = this._exportsAssign(decl.id, decl.init).expression;
if (t.isVariableDeclaration(declar)) {
for (var i in declar.declarations) {
var decl = declar.declarations[i];
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === "0") t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
assign = this._exportsAssign(declar.id, declar.id);
decl.init = this._exportsAssign(decl.id, decl.init).expression;
nodes.push(t.toStatement(declar));
nodes.push(assign);
this._hoistExport(declar, assign);
var newDeclar = t.variableDeclaration(declar.kind, [decl]);
if (i === "0") t.inherits(newDeclar, declar);
nodes.push(newDeclar);
}
} else {
var ref = declar;
if (t.isFunctionDeclaration(declar) || t.isClassDeclaration(declar)) {
ref = declar.id;
nodes.push(declar);
}
assign = this._exportsAssign(id, ref);
nodes.push(assign);
this._hoistExport(declar, assign);
}
};

View File

@@ -83,7 +83,7 @@ AMDFormatter.prototype.importSpecifier = function (specifier, node, nodes) {
if (t.isImportBatchSpecifier(specifier)) {
// import * as bar from "foo";
} else if (t.isSpecifierDefault(specifier)) {
} else if (t.isSpecifierDefault(specifier) && !this.noInteropRequire) {
// import foo from "foo";
ref = t.callExpression(this.file.addDeclaration("interop-require"), [ref]);
} else {

View File

@@ -2,12 +2,14 @@ module.exports = SystemFormatter;
var DefaultFormatter = require("./_default");
var AMDFormatter = require("./amd");
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
var _ = require("lodash");
function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.noInteropRequire = true;
AMDFormatter.apply(this, arguments);
@@ -73,12 +75,28 @@ SystemFormatter.prototype.transform = function (ast) {
EXECUTE: t.functionExpression(null, [], t.blockStatement(program.body))
}, true);
var handlerBody = runner.expression.arguments[2].body.body;
var returnStatement = handlerBody.pop();
// hoist up function declarations for circular references
traverse(program, {
enter: function (node) {
if (t.isFunction(node)) this.stop();
if (t.isFunctionDeclaration(node) || node._blockHoist) {
handlerBody.push(node);
this.remove();
}
}
});
if (!_.isEmpty(this.ids)) {
var handlerBody = runner.expression.arguments[2].body.body;
handlerBody.unshift(t.variableDeclaration("var", _.map(this.ids, function (uid) {
handlerBody.push(t.variableDeclaration("var", _.map(this.ids, function (uid) {
return t.variableDeclarator(uid);
})));
}
handlerBody.push(returnStatement);
program.body = [runner];
};

View File

@@ -0,0 +1,12 @@
(function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
});

View File

@@ -72,14 +72,13 @@ Transformer.prototype.transform = function (file) {
Transformer.prototype.canRun = function (file) {
var opts = file.opts;
var key = this.key;
if (key[0] === "_") return true;
var blacklist = opts.blacklist;
if (blacklist.length && _.contains(blacklist, key)) return false;
if (key[0] !== "_") {
var whitelist = opts.whitelist;
if (whitelist.length && !_.contains(whitelist, key)) return false;
}
var whitelist = opts.whitelist;
if (whitelist.length && !_.contains(whitelist, key)) return false;
return true;
};

View File

@@ -61,13 +61,27 @@ var pushObjectPattern = function (opts, nodes, pattern, parentId) {
};
var pushArrayPattern = function (opts, nodes, pattern, parentId) {
if (!pattern.elements) return;
var i;
var hasSpreadElement = false;
for (i in pattern.elements) {
if (t.isSpreadElement(pattern.elements[i])) {
hasSpreadElement = true;
break;
}
}
var toArray = opts.file.toArray(parentId, !hasSpreadElement && pattern.elements.length);
var _parentId = opts.file.generateUidIdentifier("ref", opts.scope);
nodes.push(t.variableDeclaration("var", [
t.variableDeclarator(_parentId, opts.file.toArray(parentId))
t.variableDeclarator(_parentId, toArray)
]));
parentId = _parentId;
for (var i in pattern.elements) {
for (i in pattern.elements) {
var elem = pattern.elements[i];
if (!elem) continue;
@@ -254,6 +268,7 @@ exports.VariableDeclaration = function (node, parent, file, scope) {
}
if (!t.isProgram(parent) && !t.isBlockStatement(parent)) {
declar = null;
for (i in nodes) {
node = nodes[i];

View File

@@ -24,6 +24,7 @@ exports.ForOfStatement = function (node, parent, file, scope) {
OBJECT: node.right
});
t.inheritsComments(node2, node);
t.ensureBlock(node);
var block = node2.body;

View File

@@ -1,26 +1,16 @@
var t = require("../../types");
var inheritsComments = function (node, nodes) {
if (nodes.length) {
t.inheritsComments(nodes[0], node);
}
};
exports.ImportDeclaration = function (node, parent, file) {
var nodes = [];
if (node.specifiers.length) {
if (!file.moduleFormatter.importSpecifier) return;
for (var i in node.specifiers) {
file.moduleFormatter.importSpecifier(node.specifiers[i], node, nodes, parent);
}
} else {
if (!file.moduleFormatter.importDeclaration) return;
file.moduleFormatter.importDeclaration(node, nodes, parent);
}
inheritsComments(node, nodes);
return nodes;
};
@@ -35,16 +25,12 @@ exports.ExportDeclaration = function (node, parent, file) {
declar.init = declar.init || t.identifier("undefined");
}
if (!file.moduleFormatter.exportDeclaration) return;
file.moduleFormatter.exportDeclaration(node, nodes, parent);
} else {
if (!file.moduleFormatter.exportSpecifier) return;
for (var i in node.specifiers) {
file.moduleFormatter.exportSpecifier(node.specifiers[i], node, nodes, parent);
}
}
inheritsComments(node, nodes);
return nodes;
};

View File

@@ -42,19 +42,35 @@ function traverse(parent, opts, scope) {
if (result != null) {
updated = true;
var isArray = _.isArray(result);
// inherit comments from original node to the first replacement node
var inheritTo = result;
if (isArray) inheritTo = result[0];
if (inheritTo) t.inheritsComments(inheritTo, node);
// replace the node
node = obj[key] = result;
if (_.isArray(result) && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
// we're replacing a statement or block node with an array of statements so we better
// ensure that it's a block
if (isArray && _.contains(t.STATEMENT_OR_BLOCK_KEYS, key) && !t.isBlockStatement(obj)) {
t.ensureBlock(obj, key);
}
}
};
var stop = false;
var stopped = false;
var removed = false;
var context = {
stop: function () {
stop = true;
stopped = true;
},
remove: function () {
stopped = removed = true;
}
};
@@ -67,8 +83,13 @@ function traverse(parent, opts, scope) {
var result = opts.enter.call(context, node, parent, ourScope);
maybeReplace(result);
if (removed) {
delete obj[key];
updated = true;
}
// stop iteration
if (stop || result === false) return;
if (stopped || result === false) return;
}
// traverse node

View File

@@ -268,7 +268,7 @@ exports.parseTemplate = function (loc, code) {
var loadTemplates = function () {
var templates = {};
var templatesLoc = __dirname + "/templates";
var templatesLoc = __dirname + "/transformation/templates";
if (!fs.existsSync(templatesLoc)) {
throw new Error("no templates directory - this is most likely the " +
"result of a broken `npm publish`. Please report to " +

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "2.0.1",
"version": "2.1.0",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -39,7 +39,7 @@
"ast-types": "~0.6.1",
"chokidar": "0.11.1",
"commander": "2.5.0",
"core-js": "^0.3.2",
"core-js": "^0.3.3",
"estraverse": "1.8.0",
"esutils": "1.1.6",
"fs-readdir-recursive": "0.1.0",

View File

@@ -33,7 +33,10 @@ switch (foo) {
}
switch (foo) {
case "foo": foo();
case "bar": bar();
default: yay();
case "foo":
foo();
case "bar":
bar();
default:
yay();
}

View File

@@ -1,18 +1,29 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = [1, 2];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
var a = _ref2[0];
var b = _ref2[1];
var _ref3 = [3, 4];
var _ref4 = _toArray(_ref3);
var _ref4 = _slicedToArray(_ref3, 2);
var c = _ref4[0];
var d = _ref4[1];

View File

@@ -1,18 +1,29 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = ["hello", [", ", "junk"], ["world"]];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 4);
var a = _ref2[0];
var _ref3 = _toArray(_ref2[1]);
var _ref3 = _slicedToArray(_ref2[1], 1);
var b = _ref3[0];
var _ref4 = _toArray(_ref2[2]);
var _ref4 = _slicedToArray(_ref2[2], 1);
var c = _ref4[0];
var d = _ref2[3];

View File

@@ -1,8 +1,19 @@
"use strict";
var _temp, _ref;
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
console.log((_temp = [123], _ref = _toArray(_temp), x = _ref[0], _temp));
console.log((_temp = [123], _ref = _slicedToArray(_temp, 1), x = _ref[0], _temp));

View File

@@ -1,12 +1,23 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = f();
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
a = _ref2[0];
b = _ref2[1];

View File

@@ -1,18 +1,29 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 5);
var a = _ref2[1];
var _ref3 = _toArray(_ref2[2]);
var _ref3 = _slicedToArray(_ref2[2], 1);
var b = _ref3[0];
var _ref4 = _toArray(_ref2[3]);
var _ref4 = _slicedToArray(_ref2[3], 1);
var c = _ref4[0];
var d = _ref2[4];

View File

@@ -1,11 +1,22 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
for (var _ref in obj) {
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
var name = _ref2[0];
var value = _ref2[1];

View File

@@ -1,12 +1,23 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
for (var _iterator = this.test.expectation.registers[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
var _ref = _step.value;
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 3);
var name = _ref2[0];
var before = _ref2[1];

View File

@@ -1,12 +1,23 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = [1, 2];
var _ref2 = _toArray(_ref);
var _ref2 = _slicedToArray(_ref, 2);
this.foo = _ref2[0];
this.bar = _ref2[1];

View File

@@ -1,14 +1,25 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
var _ref = _toArray(rect.topLeft);
var _ref = _slicedToArray(rect.topLeft, 2);
var x1 = _ref[0];
var y1 = _ref[1];
var _ref2 = _toArray(rect.bottomRight);
var _ref2 = _slicedToArray(rect.bottomRight, 2);
var x2 = _ref2[0];
var y2 = _ref2[1];

View File

@@ -1,7 +1,18 @@
"use strict";
var _toArray = function (arr) {
return Array.isArray(arr) ? arr : Array.from(arr);
var _slicedToArray = function (arr, i) {
if (Array.isArray(arr)) {
return arr;
} else {
var _arr = [];
for (var _iterator = arr[Symbol.iterator](), _step; !(_step = _iterator.next()).done;) {
_arr.push(_step.value);
if (i && _arr.length === i) break;
}
return _arr;
}
};
function somethingAdvanced(_ref) {
@@ -20,12 +31,12 @@ function unpackObject(_ref2) {
console.log(unpackObject({ title: "title", author: "author" }));
var unpackArray = function (_ref3, _ref5) {
var _ref4 = _toArray(_ref3);
var _ref4 = _slicedToArray(_ref3, 3);
var a = _ref4[0];
var b = _ref4[1];
var c = _ref4[2];
var _ref6 = _toArray(_ref5);
var _ref6 = _slicedToArray(_ref5, 3);
var x = _ref6[0];
var y = _ref6[1];

View File

@@ -17,8 +17,10 @@ _loop: for (var i in nums) {
})(i);
switch (_ret) {
case "break": break _loop;
case "continue": continue _loop;
case "break":
break _loop;
case "continue":
continue _loop;
default:
if (typeof _ret === "object") return _ret.v;
}

View File

@@ -1,6 +1,7 @@
define(["exports"], function (exports) {
"use strict";
exports["default"] = foo;
exports["default"] = 42;
exports["default"] = {};
exports["default"] = [];
@@ -10,7 +11,6 @@ define(["exports"], function (exports) {
exports["default"] = function () {};
function foo() {}
exports["default"] = foo;
var Foo = function Foo() {};
exports["default"] = Foo;

View File

@@ -1,4 +1,7 @@
System.register("es6-modules-system/exports-default/expected", [], function (_export) {
_export("default", foo);
function foo() {}
return {
setters: [],
execute: function () {
@@ -16,12 +19,9 @@ System.register("es6-modules-system/exports-default/expected", [], function (_ex
_export("default", function () {});
function foo() {}
_export("default", foo);
var Foo = function Foo() {};
_export("default", Foo);
}
};
});
});

View File

@@ -1,21 +1,21 @@
System.register("es6-modules-system/exports-variable/expected", [], function (_export) {
_export("foo7", foo7);
function foo7() {}
return {
setters: [],
execute: function () {
"use strict";
_export("foo7", foo7);
var foo = _export("foo", 1);
var foo2 = _export("foo2", function () {});
var foo3 = _export("foo3", undefined);
var foo4 = _export("foo4", 2);
var foo5 = _export("foo5", undefined);
var foo6 = _export("foo6", 3);
function foo7() {}
var foo8 = function foo8() {};
_export("foo8", foo8);
}
};
});
});

View File

@@ -1,4 +1,10 @@
System.register("es6-modules-system/hoist-function-exports/expected", ["./evens"], function (_export) {
_export("nextOdd", nextOdd);
function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
var _evens;
return {
setters: [function (m) {
@@ -7,13 +13,7 @@ System.register("es6-modules-system/hoist-function-exports/expected", ["./evens"
execute: function () {
"use strict";
_export("nextOdd", nextOdd);
var isEven = _evens.isEven;
function nextOdd(n) {
return isEven(n) ? n + 1 : n + 2;
}
var isOdd = _export("isOdd", (function (isEven) {
return function (n) {
return !isEven(n);
@@ -21,4 +21,4 @@ System.register("es6-modules-system/hoist-function-exports/expected", ["./evens"
})(isEven));
}
};
});
});

View File

@@ -7,13 +7,8 @@ System.register("es6-modules-system/imports-default/expected", ["foo"], function
execute: function () {
"use strict";
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj);
};
var foo = _interopRequire(_foo);
var foo = _interopRequire(_foo);
var foo = _foo["default"];
var foo = _foo["default"];
}
};
});
});

View File

@@ -7,13 +7,8 @@ System.register("es6-modules-system/imports-mixing/expected", ["foo"], function
execute: function () {
"use strict";
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj);
};
var foo = _interopRequire(_foo);
var foo = _foo["default"];
var xyz = _foo.baz;
}
};
});
});

View File

@@ -11,12 +11,7 @@ System.register("es6-modules-system/overview/expected", ["foo", "foo-bar", "./di
execute: function () {
"use strict";
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj);
};
var foo = _interopRequire(_foo);
var foo = _foo["default"];
var foo = _foo;
var bar = _foo.bar;
var bar = _foo.foo;
@@ -27,4 +22,4 @@ System.register("es6-modules-system/overview/expected", ["foo", "foo-bar", "./di
_export("default", test);
}
};
});
});

View File

@@ -7,6 +7,7 @@
})(function (exports) {
"use strict";
exports["default"] = foo;
exports["default"] = 42;
exports["default"] = {};
exports["default"] = [];
@@ -16,7 +17,6 @@
exports["default"] = function () {};
function foo() {}
exports["default"] = foo;
var Foo = function Foo() {};
exports["default"] = Foo;

View File

@@ -1,4 +1,4 @@
var runtime = require("../lib/6to5/runtime");
var runtime = require("../lib/6to5/runtime-generator");
var assert = require("assert");
suite("runtime", function () {