Compare commits

...

30 Commits

Author SHA1 Message Date
Sebastian McKenzie
f845633cc1 v1.12.9 2014-11-14 02:24:08 +11:00
Sebastian McKenzie
72c9b1d6c9 remove redundant changelog message 2014-11-14 02:23:23 +11:00
Sebastian McKenzie
edd3363e48 fix unicode regex test escaping 2014-11-14 02:23:12 +11:00
Sebastian McKenzie
114b5ef9ec add changelog for 1.12.9 2014-11-14 02:20:15 +11:00
Sebastian McKenzie
2f4e0c3361 escape unicode characters - fixes #154 2014-11-14 02:17:06 +11:00
Sebastian McKenzie
3ee51dae1a fix semicolon 2014-11-14 00:59:18 +11:00
Sebastian McKenzie
20263c1151 fix newline in let-scoping/for-break-continue-return test 2014-11-14 00:55:39 +11:00
Sebastian McKenzie
eaac564f11 add toIdentifier, toBlock and toStatement tests 2014-11-14 00:55:22 +11:00
Sebastian McKenzie
63a47ef7bb optimise types.toStatement for when we're directly passed a statement 2014-11-14 00:55:14 +11:00
Sebastian McKenzie
6963cc1e40 fix WithStatement missing paranthesis 2014-11-14 00:54:58 +11:00
Sebastian McKenzie
5eb2462e29 fix up semicolons for module ExportDeclaration generator 2014-11-14 00:54:28 +11:00
Sebastian McKenzie
9e285cdc20 remove unneccesary Literal generator raw 2014-11-14 00:54:12 +11:00
Sebastian McKenzie
01ade47af9 add single spread test 2014-11-14 00:54:00 +11:00
Sebastian McKenzie
b1fe449b0d allow XJSElement and SequenceExpression to be user whitespacable 2014-11-14 00:53:45 +11:00
Sebastian McKenzie
2b458ec2d4 make it illegal to use destructuring outside of an ExpressionStatement 2014-11-14 00:53:10 +11:00
Sebastian McKenzie
d5f47f4f4d generator: correctly output XJSEmptyExpression 2014-11-14 00:52:49 +11:00
Sebastian McKenzie
d4deb18975 support async functions in generator and move MethodDefinition to class generator 2014-11-14 00:52:36 +11:00
Sebastian McKenzie
5a794db73b fix up let scoping transformer comments 2014-11-14 00:52:15 +11:00
Sebastian McKenzie
dc131f05a8 add comprehensive generation tests 2014-11-14 00:51:59 +11:00
Sebastian McKenzie
1d4f79790a add brief usage to doc/index.md - thanks @gabrielecirulli ❤️ 2014-11-13 23:31:51 +11:00
Sebastian McKenzie
6bcbaf6df1 better feature code examples 2014-11-13 19:00:08 +11:00
Sebastian McKenzie
bc199ef0c9 better api documentation 2014-11-13 18:59:59 +11:00
Sebastian McKenzie
f5fed99c81 better 6to5 tagline 2014-11-13 18:59:46 +11:00
Sebastian McKenzie
66a6d3cffe add CONTRIBUTING.md 2014-11-13 18:59:29 +11:00
Sebastian McKenzie
39227486a6 add async to caveats 2014-11-13 14:47:39 +11:00
Sebastian McKenzie
caafa31df1 chagne ES6 to ES6+ when talking about 6to5 support 2014-11-13 14:47:32 +11:00
Sebastian McKenzie
4c41c904f5 v1.12.8 2014-11-13 13:42:54 +11:00
Sebastian McKenzie
0917a6a5b1 better destructuring AssignmentExpression error message 2014-11-13 13:42:18 +11:00
Sebastian McKenzie
349eba33ce add async functions to traceur differences 2014-11-13 13:40:54 +11:00
Sebastian McKenzie
8ff21b407d temporarily forbid AssignmentExpression destructuring outside of ExpressionStatement 2014-11-13 13:40:41 +11:00
157 changed files with 1005 additions and 153 deletions

View File

@@ -1,3 +1,13 @@
# 1.12.9
* Escape unicode characters when generating string `Literal`s.
* Fix semicolons being output for statements in `ExportDeclaration`.
* Fix `WithStatement` missing parenthesis.
# 1.12.8
* Temporarily forbid `AssignmentExpression` destructuring outside of `ExpressionStatement`.
# 1.12.7
* Update to latest `acorn-6to5`.

31
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,31 @@
# Contributing
* **General**
* No ES6 syntax features or methods, exclusively ES5.
* Max of five arguments for functions
* Max depth of four nested blocks
* 2-spaced soft tabs
* **Naming**
* CamelCase all class names
* camelBack all variable names
* **Spacing**
* 80 character line max
* Spaces after all keywords
* Spaces before all left curly braces
* **Comments**
* Use JSDoc-style comments for methods
* Single-line comments for ambiguous code
* **Quotes**
* Always use double quotes
* Only use single quotes when the string contains a double quote
* **Declaration**
* No unused variables
* No pollution of global variables and prototypes
## Testing
$ make test
## Linting
$ make lint

View File

@@ -24,6 +24,6 @@
</a>
</p>
**6to5** turns ES6 code into vanilla ES5, so you can use ES6 features **today.**
**6to5** turns ES6+ code into vanilla ES5, so you can use next generation features **today.**
For more information view the [documentation](https://6to5.github.io).

View File

@@ -3,12 +3,6 @@
A browser version of 6to5 is available from `browser.js` inside the 6to5
directory in an npm release.
## API
```javascript
to5.transform("class Test {}").code;
```
## Scripts
While it's not recommended for serious use, when the browser version is included
@@ -47,3 +41,21 @@ To test 6to5 in your browser run:
$ make test-browser
And open `test/browser.html` in your browser if it doesn't open automatically.
## API
### to5.transform(code, [opts])
See [options](usage.md#options) for additional documentation.
```javascript
to5.transform("class Test {}").code;
```
### to5.run(code, [opts])
See [options](usage.md#options) for additional documentation.
```javascript
to5.run("class Test {}");
```

View File

@@ -1,5 +1,10 @@
# Caveats
## Async/Generators
The [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
and an [ES6 polyfill](polyfill.md) are required in order for generators to work.
## Classes
Built-in classes such as `Date`, `Array` and `DOM` cannot be subclassed due to
@@ -32,11 +37,6 @@ A polyfill is required for for-of functionality that implements `Symbol` and
adds `prototype[Symbol.iterator]` behaviour to built-ins. Using the polyfills
specified in [polyfill](polyfill.md) suffices.
## Generators
The [regenerator runtime](https://github.com/facebook/regenerator/blob/master/runtime.js)
and an [ES6 polyfill](polyfill.md) are required in order for generators to work.
## Spread
An [ES6 polyfill](polyfill.md) is required in order for spread to work. More

View File

@@ -64,7 +64,7 @@ better suited if you'd like a full ES6 environment with polyfills and all.
| Browser support | ✓ | ✓ | ✓ | | | |
| Array comprehension | ✓ | ✓ | | | ✓ | |
| Arrow functions | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Async functions | ✓ | | ✓ | | | |
| Async functions | ✓ | | ✓ | | | |
| Classes | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Computed property names | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Constants | ✓ | ✓ | | | ✓ | |

View File

@@ -3,7 +3,32 @@
## Array comprehension
```javascript
[for (i of [1, 2, 3]) i * i]; // [1, 4, 9]
var results = [for (c of customers) if (c.city == "Seattle") { name: c.name, age: c.age }]
```
## Arrow functions
```javascript
// Expression bodies
var odds = evens.map(v => v + 1);
var nums = evens.map((v, i) => v + i);
// Statement bodies
nums.forEach(v => {
if (v % 5 === 0)
fives.push(v);
});
// Lexical this
var bob = {
_name: "Bob",
_friends: [],
printFriends() {
this._friends.forEach(f => {
console.log(this._name + " knows " + f);
});
}
};
```
## Async functions
@@ -16,31 +41,27 @@ async function chainAnimationsAsync(elem, animations) {
}
```
## Arrow functions
```javascript
arr.map(x => x * x);
```
## Let scoping
```javascript
for (let i in arr) {
let v = arr[i];
}
```
## Classes
```javascript
class Foo extends Bar {
constructor() { }
class SkinnedMesh extends THREE.Mesh {
constructor(geometry, materials) {
super(geometry, materials);
foo() { }
this.idMatrix = SkinnedMesh.defaultMatrix();
this.bones = [];
this.boneMatrices = [];
//...
}
get bar() { }
update(camera) {
//...
super.update();
}
set bar() { }
static defaultMatrix() {
return new THREE.Matrix4();
}
}
```
@@ -70,16 +91,35 @@ var MULTIPLIER; // error
## Default parameters
```javascript
function foo(bar = "foo") {
return bar + "bar";
function f(x, y = 12) {
// y is 12 if not passed (or passed as undefined)
return x + y;
}
f(3) == 15
```
## Destructuring
```javascript
var [a, [b], c, d] = ["hello", [", ", "junk"], ["world"]];
console.log(a + b + c); // hello, world
// list matching
var [a, , b] = [1,2,3];
// object matching
var { op: a, lhs: { op: b }, rhs: c } = getASTNode();
// object matching shorthand
// binds `op`, `lhs` and `rhs` in scope
var { op, lhs, rhs } = getASTNode();
// Can be used in parameter position
function g({ name: x }) {
console.log(x);
}
g({ name: 5 });
// Fail-soft destructuring
var [a] = [];
a === undefined;
```
## For-of
@@ -100,6 +140,14 @@ for (var i of [1, 2, 3]) {
```javascript
```
## Let scoping
```javascript
for (let i in arr) {
let v = arr[i];
}
```
## Modules
```javascript
@@ -141,23 +189,21 @@ function f(x, y) {
## Rest parameters
```javascript
function printList(name, ...items) {
console.log("list %s has the following items", name);
items.forEach(function (item) {
console.log(item);
});
function f(x, ...y) {
// y is an Array
return x * y.length;
}
f(3, "hello", true) == 6
```
## Spread
```javascript
function add(x, y) {
return x + y;
function f(x, y, z) {
return x + y + z;
}
var numbers = [5, 10];
add(...numbers); // 15
// Pass each elem of array as argument
f(...[1,2,3]) == 6
```
## Template literals

View File

@@ -1,4 +1,4 @@
**6to5** turns ES6 code into vanilla ES5, so you can use ES6 features **today.**
**6to5** turns ES6+ code into vanilla ES5, so you can use next generation features **today.**
- **Readable** - formatting is retained if possible so your generated code is as similar as possible.
- **Extensible** - with a large range of [plugins](plugins.md) and **browser support**.
@@ -11,6 +11,24 @@ It's as easy as:
$ npm install -g 6to5
## Usage
Once you've installed 6to5, there are multiple paths you can take depending on
how you want to use it.
6to5 will simply compile your ES6+ script to ES5 if you pass it as an argument
to the command-line tool `6to5`:
$ 6to5 script.js
If you have a file written using ES6+ and you just want to run it, `6to5-node`
has you covered:
$ 6to5-node script.js
And it doesn't end here! To see all the ways you can use 6to5, check out the
[Usage](http://6to5.github.io/usage.html) page.
## [Features](features.md)
- [Array comprehension](features.md#array-comprehension)

View File

@@ -50,16 +50,28 @@ Compile and run `test.js`.
```javascript
var to5 = require("6to5");
```
### to5.transform(code, [opts]);
```javascript
var result = to5.transform("code();", options);
result.code;
result.map;
result.ast;
```
### to5.transformFileSync(filename, [opts])
```javascript
to5.transformFileSync("filename.js", options).code;
```
### to5.transformFile(filename, [opts], callback)
```javascript
to5.transformFile("filename.js", options, function (err, result) {
result.code;
});
```

View File

@@ -2,13 +2,6 @@ var transform = module.exports = require("./transformation/transform");
transform.transform = transform;
transform.eval = function (code, opts) {
opts = opts || {};
opts.filename = opts.filename || "eval";
opts.sourceMap = "inline";
return eval(transform(code, opts).code);
};
transform.run = function (code, opts) {
opts = opts || {};
opts.sourceMap = "inline";

View File

@@ -30,3 +30,11 @@ exports.ClassBody = function (node, print) {
this.rightBrace();
}
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};

View File

@@ -74,5 +74,5 @@ exports.XJSClosingElement = function (node, print) {
};
exports.XJSEmptyExpression = function () {
this.push("null");
};

View File

@@ -41,6 +41,8 @@ exports._method = function (node, print) {
this.push(kind + " ");
}
if (value.async) this.push("async ");
if (node.computed) {
this.push("[");
print(key);
@@ -54,16 +56,9 @@ exports._method = function (node, print) {
print(value.body);
};
exports.MethodDefinition = function (node, print) {
if (node.static) {
this.push("static ");
}
this._method(node, print);
};
exports.FunctionDeclaration =
exports.FunctionExpression = function (node, print) {
if (node.async) this.push("async ");
this.push("function");
if (node.generator) this.push("*");
this.space();
@@ -74,6 +69,8 @@ exports.FunctionExpression = function (node, print) {
};
exports.ArrowFunctionExpression = function (node, print) {
if (node.async) this.push("async ");
if (node.params.length === 1 && !node.defaults.length && !node.rest && t.isIdentifier(node.params[0])) {
print(node.params[0]);
} else {

View File

@@ -25,9 +25,10 @@ exports.ExportDeclaration = function (node, print) {
if (node.declaration) {
print(node.declaration);
if (t.isStatement(node.declaration)) return;
} else {
if (specifiers.length === 1 && t.isExportBatchSpecifier(specifiers[0])) {
this.push("*");
print(specifiers[0]);
} else {
this.push("{");
if (specifiers.length) {

View File

@@ -4,6 +4,7 @@ exports.WithStatement = function (node, print) {
this.keyword("with");
this.push("(");
print(node.object);
this.push(")");
print.block(node.body);
};
@@ -134,15 +135,6 @@ exports.SwitchStatement = function (node, print) {
this.push(") {");
print.sequence(node.cases, { indent: true });
this.push("}");
//if (node.cases.length) {
// this.newline();
// print.sequence(node.cases, { indent: true });
// this.newline();
// this.rightBrace();
//} else {
// this.push("}");
//}
};
exports.SwitchCase = function (node, print) {
@@ -154,13 +146,8 @@ exports.SwitchCase = function (node, print) {
this.push("default:");
}
if (node.consequent.length === 1) {
this.space();
print(node.consequent[0]);
} else if (node.consequent.length > 1) {
this.newline();
print.sequence(node.consequent, { indent: true });
}
this.space();
print.sequence(node.consequent, { indent: true });
};
exports.DebuggerStatement = function () {

View File

@@ -74,13 +74,20 @@ exports.Literal = function (node) {
var val = node.value;
var type = typeof val;
if (type === "boolean" || type === "number" || type === "string") {
if (type === "string") {
val = JSON.stringify(val);
// escape unicode characters
val = val.replace(/[\u007f-\uffff]/g, function(c) {
return "\\u" + ("0000" + c.charCodeAt(0).toString(16)).slice(-4);
});
this.push(val);
} else if (type === "boolean" || type === "number") {
this.push(JSON.stringify(val));
} else if (node.regex) {
this.push("/" + node.regex.pattern + "/" + node.regex.flags);
} else if (val === null) {
this.push("null");
} else if (node.raw) {
this.push(node.raw);
}
};

View File

@@ -24,17 +24,14 @@ function Node(node, parent) {
}
Node.prototype.isUserWhitespacable = function () {
//var parent = this.parent;
var parent = this.parent;
var node = this.node;
if (t.isUserWhitespacable(node)) {
if (t.isUserWhitespacable(node) ||
t.isSequenceExpression(parent)) {
return true;
}
//if (t.isArrayExpression(parent)) {
// return true;
//}
return false;
};

View File

@@ -146,6 +146,12 @@ exports.ExpressionStatement = function (node, parent, file, scope) {
return nodes;
};
exports.AssignmentExpression = function (node, parent, file) {
if (parent.type === "ExpressionStatement") return;
if (!t.isPattern(node.left)) return;
throw file.errorWithNode(node, "AssignmentExpression destructuring outside of a ExpressionStatement is forbidden due to current 6to5 limitations");
};
exports.VariableDeclaration = function (node, parent, file, scope) {
if (t.isForInStatement(parent) || t.isForOfStatement(parent)) return;

View File

@@ -5,17 +5,17 @@ exports.ForOfStatement = function (node, parent, file, scope) {
var left = node.left;
var declar;
var stepKey = t.identifier(file.generateUid("step", scope));
var stepValueId = t.memberExpression(stepKey, t.identifier("value"));
var stepKey = t.identifier(file.generateUid("step", scope));
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left)) {
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValueId));
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(left.declarations[0].id, stepValueId)
t.variableDeclarator(left.declarations[0].id, stepValue)
]);
} else {
return;
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
}
var node2 = util.template("for-of", {

View File

@@ -132,7 +132,7 @@ LetScoping.prototype.run = function () {
/**
* There are no let references accessed within a closure so we can just traverse
* through this block and replace all references that exist in a high scope to
* through this block and replace all references that exist in a higher scope to
* their uids.
*/
@@ -211,7 +211,8 @@ LetScoping.prototype.getInfo = function () {
/**
* If we're inside of a `For*Statement` then traverse it and check if it has one
* of the following node types `ReturnStatement`, `BreakStatement`,
* `ContinueStatement` and replace it with a return value we can track later on.
* `ContinueStatement` and replace it with a return value that we can track
* later on.
*
* @returns {Object}
*/
@@ -251,7 +252,7 @@ LetScoping.prototype.checkFor = function () {
/**
* Hoist all var declarations in this block to before it so they retain scope
* once we wrap everything is in a closure.
* once we wrap everything in a closure.
*/
LetScoping.prototype.hoistVarDeclarations = function () {

View File

@@ -42,5 +42,6 @@
"ObjectPattern": ["Pattern"],
"ArrayPattern": ["Pattern"],
"Property": ["UserWhitespacable"]
"Property": ["UserWhitespacable"],
"XJSElement": ["UserWhitespacable"]
}

View File

@@ -106,6 +106,10 @@ t.ensureBlock = function (node) {
};
t.toStatement = function (node, ignore) {
if (t.isStatement(node)) {
return node;
}
var mustHaveId = false;
var newType;
@@ -115,8 +119,6 @@ t.toStatement = function (node, ignore) {
} else if (t.isFunction(node)) {
mustHaveId = true;
newType = "FunctionDeclaration";
} else if (t.isStatement(node)) {
newType = node.type;
}
if (mustHaveId && !node.id) {

View File

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

View File

@@ -1,3 +0,0 @@
var multiples = [for (num of nums) num * num];
var multiples = [for (num of nums) for (num2 of nums) num * num];
var multiples = [for (num of nums) if (num > 5) num * num];

View File

@@ -1,3 +0,0 @@
var multiples = [for (num of nums) num * num];
var multiples = [for (num of nums) for (num2 of nums) num * num];
var multiples = [for (num of nums) if (num > 5) num * num];

View File

@@ -1 +0,0 @@
var foo = [1, 2, 3];

View File

@@ -1 +0,0 @@
var foo = [1, 2, 3];

View File

@@ -1,17 +0,0 @@
var foo = `i
am a multiline string`;
var foo = `i am also
a multiline string
foobar`;
var foo = `im a single line string`;
var foo = tagit`i
am a multiline string`;
var foo = tagit`i am also
a multiline string
foobar`;
var foo = tagit`im a single line string`;

View File

@@ -1,17 +0,0 @@
var foo = `i
am a multiline string`;
var foo = `i am also
a multiline string
foobar`;
var foo = `im a single line string`;
var foo = tagit`i
am a multiline string`;
var foo = tagit`i am also
a multiline string
foobar`;
var foo = tagit`im a single line string`;

View File

@@ -4,6 +4,6 @@ export { a as b, c as d } from "hello";
export { a as b, c as d };
export {};
export default i = 20;
export function test() {};
export function test() {}
export var i = 20;
export let i = 42;

View File

@@ -0,0 +1,5 @@
[a, b, c];
[[], [b, c], []];
[a,, b,];
[a,,,, b];
[a, b,, c];

View File

@@ -0,0 +1,5 @@
[a, b, c];
[[], [b, c], []];
[a,, b];
[a,,,, b];
[a, b,, c];

View File

@@ -0,0 +1,4 @@
var foo = x => x * x;
var foo = (a, b) => a * b;
var foo = async x => x * x;
var foo = async (a, b) => a * b;

View File

@@ -0,0 +1,4 @@
var foo = x => x * x;
var foo = (a, b) => a * b;
var foo = async x => x * x;
var foo = async (a, b) => a * b;

View File

@@ -0,0 +1,3 @@
foo === bar;
foo + bar;
foo = bar;

View File

@@ -0,0 +1,3 @@
foo === bar;
foo + bar;
foo = bar;

View File

@@ -0,0 +1,7 @@
async function foo() {
await bar();
}
async function bar() {
await* foo();
}

View File

@@ -0,0 +1,7 @@
async function foo() {
await bar();
}
async function bar() {
await* foo();
}

View File

@@ -0,0 +1,5 @@
{}
{
foo();
}

View File

@@ -0,0 +1,5 @@
{}
{
foo();
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
break;
}
foo: for (var i in foo) {
break foo;
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
break;
}
foo: for (var i in foo) {
break foo;
}

View File

@@ -0,0 +1,5 @@
foo();
foo("foo");
foo("foo", "bar");
foo(bar());
foo(bar("test"));

View File

@@ -0,0 +1,5 @@
foo();
foo("foo");
foo("foo", "bar");
foo(bar());
foo(bar("test"));

View File

@@ -0,0 +1,13 @@
class Foo {
async foo() {}
foo() {}
["foo"]() {}
get foo() {}
set foo() {}
static async foo() {}
static foo() {}
static ["foo"]() {}
static get foo() {}
static set foo() {}
}

View File

@@ -0,0 +1,13 @@
class Foo {
async foo() {}
foo() {}
["foo"]() {}
get foo() {}
set foo() {}
static async foo() {}
static foo() {}
static ["foo"]() {}
static get foo() {}
static set foo() {}
}

View File

@@ -0,0 +1,2 @@
var foo = class Foo {};
var foo = class Foo extends Bar {};

View File

@@ -0,0 +1,2 @@
var foo = class Foo {};
var foo = class Foo extends Bar {};

View File

@@ -0,0 +1,2 @@
class Foo {}
class Foo extends Bar {}

View File

@@ -0,0 +1,2 @@
class Foo {}
class Foo extends Bar {}

View File

@@ -0,0 +1,9 @@
[for (x of nums) x * x];
[for (x of nums) if (x > 2) x * x];
[for (nums of nums2) for (x of nums) x * x];
[for (nums of nums2) for (x of nums) if (x > 2) x * x];
(for (x of nums) x * x);
(for (x of nums) if (x > 2) x * x);
(for (nums of nums2) for (x of nums) x * x);
(for (nums of nums2) for (x of nums) if (x > 2) x * x);

View File

@@ -0,0 +1,9 @@
[for (x of nums) x * x];
[for (x of nums) if (x > 2) x * x];
[for (nums of nums2) for (x of nums) x * x];
[for (nums of nums2) for (x of nums) if (x > 2) x * x];
(for (x of nums) x * x);
(for (x of nums) if (x > 2) x * x);
(for (nums of nums2) for (x of nums) x * x);
(for (nums of nums2) for (x of nums) if (x > 2) x * x);

View File

@@ -0,0 +1 @@
foo ? foo : bar;

View File

@@ -0,0 +1 @@
foo ? foo : bar;

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
continue;
}
foo: for (var i in foo) {
continue foo;
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
continue;
}
foo: for (var i in foo) {
continue foo;
}

View File

@@ -0,0 +1 @@
debugger;

View File

@@ -0,0 +1 @@
debugger;

View File

@@ -0,0 +1,5 @@
do {
test();
} while (true);
do {} while (true);

View File

@@ -0,0 +1,5 @@
do {
test();
} while (true);
do {} while (true);

View File

@@ -0,0 +1 @@
;

View File

@@ -0,0 +1 @@
;

View File

@@ -0,0 +1,27 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {};
export default class {};
export default function foo() {};
export default class Foo {};
export * from "foo";
export { foo } from "foo";
export { foo, bar } from "foo";
export { foo as bar } from "foo";
export { foo as default } from "foo";
export { foo as default, bar } from "foo";
export { foo };
export { foo, bar };
export { foo as bar };
export { foo as default };
export { foo as default, bar };
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7() {}
export class foo8 {}

View File

@@ -0,0 +1,27 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {};
export default class {};
export default function foo() {};
export default class Foo {};
export * from "foo";
export { foo } from "foo";
export { foo, bar } from "foo";
export { foo as bar } from "foo";
export { foo as default } from "foo";
export { foo as default, bar } from "foo";
export { foo };
export { foo, bar };
export { foo as bar };
export { foo as default };
export { foo as default, bar };
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7() {}
export class foo8 {}

View File

@@ -0,0 +1,5 @@
for (var i in nums) {}
for (var i in nums) {
nums[i] = nums[i] * nums[i];
}

View File

@@ -0,0 +1,5 @@
for (var i in nums) {}
for (var i in nums) {
nums[i] = nums[i] * nums[i];
}

View File

@@ -0,0 +1,5 @@
for (var x of nums) {}
for (var x of nums) {
console.log(x * x);
}

View File

@@ -0,0 +1,5 @@
for (var x of nums) {}
for (var x of nums) {
console.log(x * x);
}

View File

@@ -0,0 +1,3 @@
for (var i = 0;;) {}
for (var i = 0; i < 5;) {}
for (var i = 0; i < 5; i++) {}

View File

@@ -0,0 +1,3 @@
for (var i = 0;;) {}
for (var i = 0; i < 5;) {}
for (var i = 0; i < 5; i++) {}

View File

@@ -0,0 +1,23 @@
function foo(bar = "bar") {}
function foo(bar = "bar", ...items) {}
function foo(...items) {}
function* foo() {}
function foo() {}
async function foo() {}
var foo = function* foo() {};
var foo = function foo() {};
var foo = async function foo() {};
var foo = function* () {};
var foo = function () {};
var foo = async function () {};

View File

@@ -0,0 +1,23 @@
function foo(bar = "bar") {}
function foo(bar = "bar", ...items) {}
function foo(...items) {}
function* foo() {}
function foo() {}
async function foo() {}
var foo = function* foo() {};
var foo = function foo() {};
var foo = async function foo() {};
var foo = function* () {};
var foo = function () {};
var foo = async function () {};

View File

@@ -0,0 +1,2 @@
foo;
undefined;

View File

@@ -0,0 +1,2 @@
foo;
undefined;

View File

@@ -0,0 +1,25 @@
if (foo) foobar();
if (foo) {
foobar();
}
if (foo) {}
if (foo) {
foo();
} else bar();
if (foo) {
foo();
} else {
bar();
}
if (foo) {
foo();
} else if (bar) {
foobar();
} else {
bar();
}

View File

@@ -0,0 +1,25 @@
if (foo) foobar();
if (foo) {
foobar();
}
if (foo) {}
if (foo) {
foo();
} else bar();
if (foo) {
foo();
} else {
bar();
}
if (foo) {
foo();
} else if (bar) {
foobar();
} else {
bar();
}

View File

@@ -0,0 +1,9 @@
import "foo";
import foo from "foo";
import { default as foo } from "foo";
import * as foo from "foo";
import foo, { baz as xyz } from "foo";
import { bar } from "foo";
import { bar, baz } from "foo";
import { bar as baz } from "foo";
import { bar as baz, xyz } from "foo";

View File

@@ -0,0 +1,9 @@
import "foo";
import foo from "foo";
import { default as foo } from "foo";
import * as foo from "foo";
import foo, { baz as xyz } from "foo";
import { bar } from "foo";
import { bar, baz } from "foo";
import { bar as baz } from "foo";
import { bar as baz, xyz } from "foo";

View File

@@ -0,0 +1 @@
label: for (var i in test) {}

View File

@@ -0,0 +1 @@
label: for (var i in test) {}

View File

@@ -0,0 +1,7 @@
5;
"foobar";
"\n\r\u2028\u2029";
/foobar/g;
null;
true;
false;

View File

@@ -0,0 +1,7 @@
5;
"foobar";
"\n\r\u2028\u2029";
/foobar/g;
null;
true;
false;

View File

@@ -0,0 +1,8 @@
foo["bar"];
foo.bar;
foo.bar.foo;
foo.bar["foo"];
foo["foo"]["bar"];
foo[test()][bar()];

View File

@@ -0,0 +1,8 @@
foo["bar"];
foo.bar;
foo.bar.foo;
foo.bar["foo"];
foo["foo"]["bar"];
foo[test()][bar()];

View File

@@ -0,0 +1,3 @@
new Foo;
new Foo();
new Foo(bar);

View File

@@ -0,0 +1,3 @@
new Foo();
new Foo();
new Foo(bar);

View File

@@ -0,0 +1,20 @@
var foo = {};
var foo = { x, y };
var foo = { x: x, y: y };
var foo = {
x: x,
y: y
};
var foo = {
["bar"]: "foo",
["foo"]() {},
foo() {},
async foo() {},
*foo() {},
get foo() {},
set foo() {}
};

View File

@@ -0,0 +1,20 @@
var foo = {};
var foo = { x, y };
var foo = { x: x, y: y };
var foo = {
x: x,
y: y
};
var foo = {
["bar"]: "foo",
["foo"]() {},
foo() {},
async foo() {},
*foo() {},
get foo() {},
set foo() {}
};

Some files were not shown because too many files have changed in this diff Show More