Compare commits

...

8 Commits

Author SHA1 Message Date
Sebastian McKenzie
75ece96475 v1.10.6 2014-10-28 13:18:47 +11:00
Sebastian McKenzie
b016fda8af add browser.js to .gitignore 2014-10-28 13:18:00 +11:00
Sebastian McKenzie
2cffad61fa more reliable destructuring building 2014-10-28 13:16:31 +11:00
Sebastian McKenzie
4e248c0a16 add member expression destructuring test 2014-10-28 13:16:21 +11:00
Sebastian McKenzie
4f5026101b fix cache-templates build script position - fixes #101 2014-10-28 13:16:08 +11:00
Sebastian McKenzie
4ce38eab37 v1.10.5 2014-10-28 10:59:28 +11:00
Sebastian McKenzie
0a7ce115ff remove browser.js in make publish 2014-10-28 10:58:29 +11:00
Sebastian McKenzie
21ed438fd8 alias functions in scope call wrapping - fixes #99 2014-10-28 10:58:20 +11:00
7 changed files with 25 additions and 20 deletions

1
.gitignore vendored
View File

@@ -4,5 +4,6 @@ test/tmp
*.log
*.cache
/templates.json
/browser.js
coverage
dist

View File

@@ -45,16 +45,16 @@ publish:
make test
node bin/cache-templates
test -f templates.json
make build
cp dist/6to5.js browser.js
node bin/cache-templates
test -f templates.json
read -p "Version: " version; \
npm version $$version --message "v%s"
npm publish
git push --follow-tags
rm -rf templates.json
rm -rf templates.json browser.js

View File

@@ -13,11 +13,15 @@ var buildVariableAssign = function (kind, id, init) {
}
};
var push = function (kind, nodes, pattern, parentId) {
if (pattern.type === "ObjectPattern") {
pushObjectPattern(kind, nodes, pattern, parentId);
} else if (pattern.type === "ArrayPattern") {
pushArrayPattern(kind, nodes, pattern, parentId);
var push = function (kind, nodes, elem, parentId) {
if (elem.type === "ObjectPattern") {
pushObjectPattern(kind, nodes, elem, parentId);
} else if (elem.type === "ArrayPattern") {
pushArrayPattern(kind, nodes, elem, parentId);
} else if (elem.type === "MemberExpression") {
nodes.push(buildVariableAssign(false, elem, parentId));
} else {
nodes.push(buildVariableAssign(kind, elem, parentId));
}
};
@@ -39,14 +43,7 @@ var pushArrayPattern = function (kind, nodes, pattern, parentId) {
if (!elem) return;
var newPatternId = b.memberExpression(parentId, b.literal(i), true);
if (elem.type === "Identifier") {
nodes.push(buildVariableAssign(kind, elem, newPatternId));
} else if (elem.type === "MemberExpression") {
nodes.push(buildVariableAssign(false, elem, newPatternId));
} else {
push(kind, nodes, elem, newPatternId);
}
push(kind, nodes, elem, newPatternId);
});
};

View File

@@ -42,9 +42,11 @@ exports.VariableDeclaration = function (node, parent, file) {
if (node.type === "FunctionDeclaration") {
throw new Error("`FunctionDeclaration`s that use `let` and `constant` references aren't allowed outside of the root scope");
} else {
return b.callExpression(b.functionExpression(null, letReferences, b.blockStatement([
var func = b.functionExpression(null, letReferences, b.blockStatement([
b.returnStatement(node)
])), letReferences);
]));
func._aliasFunction = true;
return b.callExpression(func, letReferences);
}
} else {
return false;

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "1.10.4",
"version": "1.10.6",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/sebmck/6to5",
"repository": {

View File

@@ -0,0 +1 @@
[this.foo, this.bar] = [1, 2];

View File

@@ -0,0 +1,4 @@
"use strict";
var _ref = [1, 2];
this.foo = _ref[0];
this.bar = _ref[1];