Compare commits

...

77 Commits

Author SHA1 Message Date
Sebastian McKenzie
54f8889a30 v2.10.1 2015-01-12 20:09:54 +11:00
Sebastian McKenzie
bab159bc08 fix version number in changelog 2015-01-12 20:08:14 +11:00
Sebastian McKenzie
23950963e5 add upgrade core-js note 2015-01-12 20:07:51 +11:00
Sebastian McKenzie
d1daac5550 add global shim due to core-js 0.4.4 2015-01-12 20:07:30 +11:00
Sebastian McKenzie
d93ece5ccf add 2.10.11 changelog 2015-01-12 20:05:19 +11:00
Sebastian McKenzie
c8c667bf16 add back loop ensure block 2015-01-12 20:04:19 +11:00
Sebastian McKenzie
49cdacbcb4 add includeRegenerator option 2015-01-12 20:03:02 +11:00
Sebastian McKenzie
f97bd584f7 upgrade core-js 2015-01-12 19:49:04 +11:00
Sebastian McKenzie
f1328aa82f v2.10.0 2015-01-12 11:52:32 +11:00
Sebastian McKenzie
e298a5d350 remove unused check function 2015-01-12 11:50:45 +11:00
Sebastian McKenzie
89a6ef0b26 add 2.10.0 changelog 2015-01-12 11:50:19 +11:00
Sebastian McKenzie
c7ac9b7815 rename --reactCompat arg to --react-compat 2015-01-12 11:47:04 +11:00
Sebastian McKenzie
55c99b9122 upgrade acorn-6to5 2015-01-12 11:45:21 +11:00
Sebastian McKenzie
545c8c3adb define class methods instead of assigning them - fixes #454 2015-01-12 11:44:23 +11:00
Sebastian McKenzie
d093dc8231 disallow setters without one parameter - fixes #455 2015-01-12 10:25:37 +11:00
Sebastian McKenzie
eaf9d58b8d Merge branch 'master' of github.com:6to5/6to5 2015-01-12 10:19:53 +11:00
Sebastian McKenzie
6131cea5b2 add classesFastSuper optional transformer - fixes #451 2015-01-12 10:19:22 +11:00
Sebastian McKenzie
ca4831febe Merge pull request #453 from amasad/master
Add --reactCompat option to cli
2015-01-12 09:57:21 +11:00
Amjad Masad
9cf8d05a19 Add --reactCompat option to cli 2015-01-11 12:47:17 -05:00
Sebastian McKenzie
2a4f03330b better bin name for 6to5-node 2015-01-11 22:59:36 +11:00
Sebastian McKenzie
83bc614bad add note about splitting up super transforming #411 2015-01-11 22:42:45 +11:00
Sebastian McKenzie
99ccb4111a start adding support for this mapping for supers 2015-01-11 22:15:56 +11:00
Sebastian McKenzie
f6c72e9ae9 add newline to scope 2015-01-11 22:15:56 +11:00
Sebastian McKenzie
a90730d4bf Merge pull request #449 from monsanto/fix-6to5-node-name
fix _6to5-node name in help screen
2015-01-11 18:19:04 +11:00
Christopher Monsanto
29503d2d37 fix _6to5-node name in help screen 2015-01-10 23:04:13 -05:00
Sebastian McKenzie
35451ed408 Merge pull request #447 from fkling/cli
Fix short --whitelist option
2015-01-11 11:21:41 +11:00
Felix Kling
7167aeb65a Fix short --whitelist option
`6to5 -w generators` doesn't work because `-w` is also short for
`--watch`. This changes the short option for `--whitelist` to `-l`.
2015-01-10 11:03:26 -08:00
Sebastian McKenzie
29d0489443 add autoindentation note 2015-01-11 04:55:34 +11:00
Sebastian McKenzie
82aa2686f9 fix writable being set on accessors 2015-01-11 04:55:27 +11:00
Sebastian McKenzie
24616fa08a fix linting errors 2015-01-11 03:35:37 +11:00
Sebastian McKenzie
9f3e1eabfd simplify define properties 2015-01-11 03:21:05 +11:00
Sebastian McKenzie
286d2f84bd add configurable and writable property to defined properties 2015-01-11 02:43:17 +11:00
Sebastian McKenzie
7fc484d82e add ES5 getter/setter split up note - closes #444 2015-01-11 02:30:11 +11:00
Sebastian McKenzie
ad6ab57fe3 only use raw type references in coreAliasing on Symbol - fixes #421 2015-01-11 01:00:04 +11:00
Sebastian McKenzie
348fe045d3 reformat for of transformers and add pattern support 2015-01-11 00:35:41 +11:00
Sebastian McKenzie
980b20316b Merge pull request #441 from monsanto/fast-for-of
Optional for-of transformer that puts arrays in fast path
2015-01-11 00:32:56 +11:00
Sebastian McKenzie
5b52e507ca fix non-identifier class super tests 2015-01-10 22:55:19 +11:00
Sebastian McKenzie
9853c9d78d add empty statement case to toBlock 2015-01-10 22:42:35 +11:00
Sebastian McKenzie
72ec771725 fix unnecessarily shifting super ref 2015-01-10 22:42:20 +11:00
Sebastian McKenzie
75e97d9f7e format scope default declarations better 2015-01-10 22:34:08 +11:00
Sebastian McKenzie
295faf185c remove unnecessary ensureBlock in let scoping transformer #434 2015-01-10 22:33:57 +11:00
Sebastian McKenzie
54b05f33f2 move super reference into closure 2015-01-10 22:26:51 +11:00
Sebastian McKenzie
1985146760 use Array.isArray instead of _.isArray 2015-01-10 22:26:37 +11:00
Sebastian McKenzie
13a52dd300 always use an IIFE for classes - fixes #435 2015-01-10 22:18:30 +11:00
Sebastian McKenzie
9d4bea70e6 Merge pull request #433 from gaearon/perf-traverse-refactor
Refactor traversal to avoid closures for perf
2015-01-10 22:06:08 +11:00
Dan Abramov
421906bcc1 Refactor traversal to avoid closures 2015-01-10 14:02:08 +03:00
Sebastian McKenzie
508b3531e5 Merge pull request #432 from gaearon/perf-stable
Replace _.each and for-in with for loop in hot paths
2015-01-10 21:49:37 +11:00
Sebastian McKenzie
c67c407cd0 v2.9.4 2015-01-10 16:28:02 +11:00
Sebastian McKenzie
aa552fea0d add 2.9.4 changelog 2015-01-10 16:25:39 +11:00
Sebastian McKenzie
9bbf109dc8 support UpdateExpressions as MemberExpression objects - fixes #440 2015-01-10 16:24:17 +11:00
Christopher Monsanto
393d52088a optional for-of transformer that puts arrays in fast path 2015-01-09 20:53:48 -05:00
Dan Abramov
5783973734 A few minor perf improvements 2015-01-09 22:00:07 +03:00
Dan Abramov
55e01afd0d Improve performance on hot paths by using for loops 2015-01-09 16:51:34 +03:00
Dan Abramov
1231dc6cef Replace _.each and for-in with for loop in hot paths 2015-01-09 16:00:53 +03:00
Sebastian McKenzie
b08f2061b5 fix destructuring tests 2015-01-09 21:43:24 +11:00
Sebastian McKenzie
1536d3de91 Revert "add base optional object observe transformer"
This reverts commit b619e843a9.
2015-01-09 21:18:55 +11:00
Sebastian McKenzie
fddacb1612 don't assign array expressions to a temp variable in destructuring #431 2015-01-09 21:18:51 +11:00
Sebastian McKenzie
9d1ff2b71b v2.9.3 2015-01-09 20:10:17 +11:00
Sebastian McKenzie
1c8d24f78c remove exportsWildcard helper in favor of defaults #430 2015-01-09 20:08:05 +11:00
Sebastian McKenzie
b619e843a9 add base optional object observe transformer 2015-01-09 19:57:21 +11:00
Sebastian McKenzie
e6a71c5849 move npm version up 2015-01-09 19:56:22 +11:00
Sebastian McKenzie
682668c219 v2.9.2 2015-01-09 19:51:44 +11:00
Sebastian McKenzie
dd64297838 add 2.9.2 changelog 2015-01-09 19:49:10 +11:00
Sebastian McKenzie
944a9d3908 pass exports to exportsWildcard - fixes #430 2015-01-09 19:48:11 +11:00
Sebastian McKenzie
d6922c9b75 v2.9.1 2015-01-09 19:34:28 +11:00
Sebastian McKenzie
fb0fcc7138 fix runtime generator breaking the helper inclusion loop - fixes #429 2015-01-09 19:31:43 +11:00
Sebastian McKenzie
89148e6029 Merge pull request #424 from 6to5/more-super-issues
Ensure more than one level of superclass works.
2015-01-09 08:35:40 +11:00
Brian Donovan
28d10b8eb4 Ensure more than one level of superclass works. 2015-01-08 13:33:02 -08:00
Sebastian McKenzie
3509990563 enable esnext tests by default 2015-01-09 07:23:17 +11:00
Sebastian McKenzie
c5960fb9f7 Merge pull request #408 from 6to5/fix-esnext-class-tests
[WIP] Fix super with getters and setters and with class prototypes changing.
2015-01-09 07:22:35 +11:00
Brian Donovan
07131576cf Use undefined instead of void 0. 2015-01-08 11:59:01 -08:00
Sebastian McKenzie
e75e778300 v2.9.0 2015-01-09 06:02:43 +11:00
Sebastian McKenzie
f6cb14c975 upgrade acorn-6to5 2015-01-09 06:00:19 +11:00
Brian Donovan
af1912ab7a Ensure constructors use the current super class.
This is an extension of 324a4a1b22.
2015-01-08 09:31:18 -08:00
Brian Donovan
8c478f29bc Use desc.writable instead of "writable" in desc as suggested by @stefanpenner. 2015-01-08 09:21:35 -08:00
Brian Donovan
5b4d6d7ba9 Replace superIdentifier with superProperty.
This also disallows the usage of bare `super` that is not part of a
member expression, call expression, or new expression.
2015-01-08 09:21:32 -08:00
Brian Donovan
324a4a1b22 Fix super with getters and setters and with class prototypes changing. 2015-01-07 21:10:36 -08:00
97 changed files with 1314 additions and 582 deletions

View File

@@ -11,6 +11,55 @@
_Note: Gaps between patch versions are faulty/broken releases._
## 2.10.1
* **Internal**
* Upgrade `core-js` to `0.4.4`.
* **New Feature**
* Added `--include-regenerator` option to CLI and `includeRegenerator` option to API that includes the regenerator runtime if necessary.
## 2.10.0
* **New Feature**
* Add `classesFastSuper` optional transformer that doesn't support parent getters and prototype changing.
* Add `forOfFast` transformer that speeds up `for...of` on arrays but produces more code.
* Add `--react-compat` to `bin/6to5`.
* **Spec Compliancy**
* Disallow setters without a single parameter.
* Add `configurable` and `writable` to defined properties.
* Use define instead of assignment for class methods.
* **Polish**
* Fix bin name in `6to5-node --help`.
* Fix shorthand `--whitelist` name in `bin/6to5`.
* **Internal**
* Hot code optimisation of traversal etc thanks to [gaearon](https://github.com/gaearon).
## 2.9.4
* **Bug Fix**
* Support `UpdateExpression`s as `MemberExpression` objects.
## 2.9.3
* **Bug Fix**
* Remove `exportsWildcard` helper in favor of `defaults`.
## 2.9.2
* **Bug Fix**
* Pass `exports` to `exportWildcard` helper to allow for use inside the optional runtime.
## 2.9.1
* **Bug Fix**
* Fix runtime generator breaking the helper inclusion loop.
## 2.9.0
* **Internal**
* Upgrade `acorn-6to5`.
* Now supports destructuring shorthand properties.
## 2.8.1
* **Bug Fix**

View File

@@ -71,6 +71,9 @@ publish:
make test
read -p "Version: " version; \
npm version $$version --message "v%s"
make build
cp dist/6to5.min.js browser.js
cp dist/polyfill.min.js browser-polyfill.js
@@ -79,8 +82,6 @@ publish:
node bin/cache-templates
test -f templates.json
read -p "Version: " version; \
npm version $$version --message "v%s"
npm publish
git push --follow-tags

View File

@@ -7,3 +7,6 @@
* Remove `allowImportExportEverywhere` option from acorn.
* Remove this shorthand from playground.
* Remove `super()` inside non-constructors - add descriptive error message.
* Split up ES5 getter/setter transforming and ES6 property methods into separate transformers.
* Add autoindentation.
* Move `super` transformation from classes into a separate transformer that also supports object expressions.

View File

@@ -15,7 +15,7 @@ commander.option("-e, --experimental", "Enable experimental support for proposed
commander.option("-p, --playground", "Enable playground support");
commander.option("-m, --modules [modules]", "Module formatter type to use [common]", "common");
commander.option("-w, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-l, --whitelist [whitelist]", "Whitelist of transformers to ONLY use", util.list);
commander.option("-b, --blacklist [blacklist]", "Blacklist of transformers to NOT use", util.list);
commander.option("-i, --optional [list]", "List of optional transformers to enable", util.list);
commander.option("-o, --out-file [out]", "Compile all input files into a single file");
@@ -24,6 +24,8 @@ commander.option("-c, --remove-comments", "Remove comments from the compiled cod
commander.option("-I, --indent [width]", "Indent width [2]", 2);
commander.option("-a, --amd-module-ids", "Insert module id in AMD modules", false); // todo: remove in 3.0.0
commander.option("-m, --module-ids", "Insert module id in modules", false);
commander.option("-R, --react-compat", "Makes the react transformer produce pre-v0.12 code");
commander.option("-E, --include-regenerator", "Include the regenerator runtime if necessary", false);
commander.on("--help", function(){
var outKeys = function (title, obj) {
@@ -99,17 +101,19 @@ if (errors.length) {
//
exports.opts = {
sourceMapName: commander.outFile,
experimental: commander.experimental,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules,
includeRegenerator: commander.includeRegenerator,
sourceMapName: commander.outFile,
experimental: commander.experimental,
reactCompat: commander.reactCompat,
playground: commander.playground,
moduleIds: commander.amdModuleIds || commander.moduleIds,
blacklist: commander.blacklist,
whitelist: commander.whitelist,
sourceMap: commander.sourceMaps || commander.sourceMapsInline,
optional: commander.optional,
comments: !commander.removeComments,
runtime: commander.runtime,
modules: commander.modules,
format: {
indent: {
style: util.repeat(parseInt(commander.indent))

View File

@@ -10,29 +10,31 @@ var util = require("../lib/6to5/util");
var vm = require("vm");
var _ = require("lodash");
commander.option("-e, --eval [script]", "Evaluate script");
commander.option("-p, --print", "Evaluate script and print result");
commander.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
commander.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js]");
commander.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
commander.option("-g, --playground", "Enable playground support");
commander.option("-c, --cache", "Cache compiled files and require paths");
var program = new commander.Command("6to5-node");
program.option("-e, --eval [script]", "Evaluate script");
program.option("-p, --print", "Evaluate script and print result");
program.option("-i, --ignore [regex]", "Ignore all files that match this regex when using the require hook");
program.option("-x, --extensions [extensions]", "List of extensions to hook into [.es6,.js]");
program.option("-r, --experimental", "Enable experimental support for proposed ES7 features");
program.option("-g, --playground", "Enable playground support");
program.option("-c, --cache", "Cache compiled files and require paths");
var pkg = require("../package.json");
commander.version(pkg.version);
commander.usage("[options] [ -e script | script.js ] [arguments]");
commander.parse(process.argv);
program.version(pkg.version);
program.usage("[options] [ -e script | script.js ] [arguments]");
program.parse(process.argv);
if (commander.cache) roadrunner.load();
if (program.cache) roadrunner.load();
//
to5.register({
experimental: commander.experimental,
extensions: commander.extensions,
playground: commander.playground,
ignore: commander.ignore,
cache: commander.cache && roadrunner.get("6to5")
experimental: program.experimental,
extensions: program.extensions,
playground: program.playground,
ignore: program.ignore,
cache: program.cache && roadrunner.get("6to5")
});
//
@@ -41,17 +43,17 @@ var _eval = function (code, filename) {
code = to5.transform(code, {
filename: filename,
blacklist: ["useStrict"],
experimental: commander.experimental,
playground: commander.playground
experimental: program.experimental,
playground: program.playground
}).code;
return vm.runInThisContext(code, filename);
};
if (commander.eval) {
var result = _eval(commander.eval, "eval");
if (commander.print) console.log(result);
if (program.eval) {
var result = _eval(program.eval, "eval");
if (program.print) console.log(result);
} else {
if (commander.args.length) {
if (program.args.length) {
// slice all arguments up to the first filename since they're 6to5 args that we handle
var args = process.argv.slice(2);
@@ -77,7 +79,7 @@ if (commander.eval) {
}
}
if (commander.cache) roadrunner.save();
if (program.cache) roadrunner.save();
function replStart() {
repl.start({

View File

@@ -35,8 +35,8 @@ File.helpers = [
"async-to-generator",
"interop-require-wildcard",
"typeof",
"exports-wildcard",
"extends"
"extends",
"get"
];
File.excludeHelpersFromRuntime = [
@@ -48,21 +48,22 @@ File.normaliseOptions = function (opts) {
opts = _.cloneDeep(opts || {});
_.defaults(opts, {
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
code: true,
ast: true
includeRegenerator: false,
experimental: false,
reactCompat: false,
playground: false,
whitespace: true,
moduleIds: opts.amdModuleIds || false,
blacklist: [],
whitelist: [],
sourceMap: false,
optional: [],
comments: true,
filename: "unknown",
modules: "common",
runtime: false,
code: true,
ast: true
});
// normalise windows path separators to unix

View File

@@ -61,7 +61,7 @@ Buffer.prototype.space = function () {
Buffer.prototype.removeLast = function (cha) {
if (!this.isLast(cha)) return;
this.buf = this.buf.slice(0, -1);
this.buf = this.buf.substr(0, this.buf.length - 1);
this.position.unshift(cha);
};
@@ -77,10 +77,9 @@ Buffer.prototype.newline = function (i, removeLast) {
if (this.endsWith("{\n")) i--;
if (this.endsWith(util.repeat(i, "\n"))) return;
var self = this;
_.times(i, function () {
self.newline(null, removeLast);
});
for (var j = 0; j < i; j++) {
this.newline(null, removeLast);
}
return;
}
@@ -115,13 +114,18 @@ Buffer.prototype._push = function (str) {
};
Buffer.prototype.endsWith = function (str) {
return this.buf.slice(-str.length) === str;
var d = this.buf.length - str.length;
return d >= 0 && this.buf.lastIndexOf(str) === d;
};
Buffer.prototype.isLast = function (cha, trimRight) {
var buf = this.buf;
if (trimRight) buf = util.trimRight(buf);
var last = buf[buf.length - 1];
var chars = [].concat(cha);
return _.contains(chars, _.last(buf));
if (Array.isArray(cha)) {
return _.contains(cha, last);
} else {
return cha === last;
}
};

View File

@@ -6,14 +6,19 @@ var t = require("../../types");
var _ = require("lodash");
var find = function (obj, node, parent) {
if (!obj) return;
var result;
_.each(obj, function (fn, type) {
var types = Object.keys(obj);
for (var i = 0; i < types.length; i++) {
var type = types[i];
if (t["is" + type](node)) {
var fn = obj[type];
result = fn(node, parent);
if (result != null) return false;
if (result != null) break;
}
});
}
return result;
};
@@ -99,7 +104,13 @@ _.each(Node.prototype, function (fn, key) {
Node[key] = function (node, parent) {
var n = new Node(node, parent);
var args = _.toArray(arguments).slice(2);
// Avoid leaking arguments to prevent deoptimization
var skipCount = 2;
var args = new Array(arguments.length - skipCount);
for (var i = 0; i < args.length; i++) {
args[i] = arguments[i + 2];
}
return n[key].apply(n, args);
};
});

View File

@@ -21,6 +21,13 @@ _.each([
});
});
exports.UpdateExpression = function (node, parent) {
if (t.isMemberExpression(parent) && parent.object === node) {
// (foo++).test()
return true;
}
};
exports.ObjectExpression = function (node, parent) {
if (t.isExpressionStatement(parent)) {
// ({ foo: "bar" });

View File

@@ -1,33 +1,27 @@
module.exports = Position;
var _ = require("lodash");
function Position() {
this.line = 1;
this.column = 0;
}
Position.prototype.push = function (str) {
var self = this;
_.each(str, function (cha) {
if (cha === "\n") {
self.line++;
self.column = 0;
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line++;
this.column = 0;
} else {
self.column++;
this.column++;
}
});
}
};
Position.prototype.unshift = function (str) {
var self = this;
_.each(str, function (cha) {
if (cha === "\n") {
self.line--;
for (var i = 0; i < str.length; i++) {
if (str[i] === "\n") {
this.line--;
} else {
self.column--;
this.column--;
}
});
}
};

View File

@@ -11,15 +11,18 @@ Whitespace.prototype.getNewlinesBefore = function (node) {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var i = 0; i < tokens.length; i++) {
token = tokens[i];
_.each(tokens, function (token, i) {
// this is the token this node starts with
if (node.start === token.start) {
startToken = tokens[i - 1];
endToken = token;
return false;
break;
}
});
}
return this.getNewlinesBetween(startToken, endToken);
};
@@ -28,15 +31,18 @@ Whitespace.prototype.getNewlinesAfter = function (node) {
var startToken;
var endToken;
var tokens = this.tokens;
var token;
for (var i = 0; i < tokens.length; i++) {
token = tokens[i];
_.each(tokens, function (token, i) {
// this is the token this node ends with
if (node.end === token.end) {
startToken = token;
endToken = tokens[i + 1];
return false;
break;
}
});
}
if (endToken.type.type === "eof") {
return 1;

View File

@@ -20,7 +20,7 @@ module.exports = function (namespace) {
_.each(File.helpers, function (name) {
if (_.contains(File.excludeHelpersFromRuntime, name)) {
return false;
return;
}
var key = t.identifier(t.toIdentifier(name));

View File

@@ -217,7 +217,8 @@ DefaultFormatter.prototype._exportSpecifier = function (getRef, specifier, node,
};
DefaultFormatter.prototype._exportsWildcard = function (objectIdentifier) {
return t.expressionStatement(t.callExpression(this.file.addHelper("exports-wildcard"), [
return t.expressionStatement(t.callExpression(this.file.addHelper("defaults"), [
t.identifier("exports"),
t.callExpression(this.file.addHelper("interop-require-wildcard"), [objectIdentifier])
]));
};

View File

@@ -0,0 +1,5 @@
(function () {
if (SUPER_NAME != null) {
SUPER_NAME.apply(this, arguments);
}
});

View File

@@ -1,3 +1,3 @@
if (SUPER_NAME !== null) {
SUPER_NAME.apply(this, arguments);
if (Object.getPrototypeOf(CLASS_NAME) !== null) {
Object.getPrototypeOf(CLASS_NAME).apply(this, arguments);
}

View File

@@ -1,7 +0,0 @@
(function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
}
}
})

View File

@@ -0,0 +1,13 @@
for (var LOOP_OBJECT = OBJECT,
IS_ARRAY = Array.isArray(LOOP_OBJECT),
INDEX = 0,
LOOP_OBJECT = IS_ARRAY ? LOOP_OBJECT : LOOP_OBJECT[Symbol.iterator]();;) {
if (IS_ARRAY) {
if (INDEX >= LOOP_OBJECT.length) break;
ID = LOOP_OBJECT[INDEX++];
} else {
INDEX = LOOP_OBJECT.next();
if (INDEX.done) break;
ID = INDEX.value;
}
}

View File

@@ -0,0 +1,23 @@
(function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
});

View File

@@ -1,5 +0,0 @@
(function (KEY) {
CONTENT;
return KEY;
})(OBJECT);

View File

@@ -1 +0,0 @@
Object.defineProperties(OBJECT, PROPS);

View File

@@ -43,6 +43,7 @@ transform.moduleFormatters = {
_.each({
specNoForInOfAssignment: require("./transformers/spec-no-for-in-of-assignment"),
specSetters: require("./transformers/spec-setters"),
// playground
methodBinding: require("./transformers/playground-method-binding"),
@@ -58,6 +59,7 @@ _.each({
arrayComprehension: require("./transformers/es7-array-comprehension"),
generatorComprehension: require("./transformers/es7-generator-comprehension"),
arrowFunctions: require("./transformers/es6-arrow-functions"),
classesFastSuper: require("./transformers/optional-classes-fast-super"),
classes: require("./transformers/es6-classes"),
objectSpread: require("./transformers/es7-object-spread"),
@@ -68,6 +70,7 @@ _.each({
computedPropertyNames: require("./transformers/es6-computed-property-names"),
destructuring: require("./transformers/es6-destructuring"),
defaultParameters: require("./transformers/es6-default-parameters"),
forOfFast: require("./transformers/optional-for-of-fast"),
forOf: require("./transformers/es6-for-of"),
unicodeRegex: require("./transformers/es6-unicode-regex"),
abstractReferences: require("./transformers/es7-abstract-references"),

View File

@@ -3,36 +3,11 @@ var util = require("../../util");
var t = require("../../types");
exports.ClassDeclaration = function (node, parent, file, scope) {
var closure = true;
if (t.isProgram(parent) || t.isBlockStatement(parent)) {
closure = false;
}
var factory = new Class(node, file, scope, closure);
var newNode = factory.run();
if (factory.closure) {
if (closure) {
// declaration in an expression context...
// export default class Foo {}
scope.push({
kind: "var",
key: node.id.key,
id: node.id
});
return t.assignmentExpression("=", node.id, newNode);
} else {
// has a super class or PrivateDeclaration etc
return t.variableDeclaration("let", [
t.variableDeclarator(node.id, newNode)
]);
}
} else {
return newNode;
}
return new Class(node, file, scope, true).run();
};
exports.ClassExpression = function (node, parent, file, scope) {
return new Class(node, file, scope, true).run();
return new Class(node, file, scope, false).run();
};
/**
@@ -44,11 +19,11 @@ exports.ClassExpression = function (node, parent, file, scope) {
* @param {Boolean} closure
*/
function Class(node, file, scope, closure) {
this.closure = closure;
this.scope = scope;
this.node = node;
this.file = file;
function Class(node, file, scope, isStatement) {
this.isStatement = isStatement;
this.scope = scope;
this.node = node;
this.file = file;
this.hasInstanceMutators = false;
this.hasStaticMutators = false;
@@ -83,17 +58,20 @@ Class.prototype.run = function () {
t.variableDeclarator(className, constructor)
]));
var closureArgs = [];
var closureParams = [];
//
if (superName) {
this.closure = true;
closureArgs.push(superName);
// so we're only evaluating it once
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
body.unshift(t.variableDeclaration("var", [
t.variableDeclarator(superRef, superName)
]));
superName = superRef;
if (!t.isIdentifier(superName)) {
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
superName = superRef;
}
closureParams.push(superName);
this.superName = superName;
body.push(t.expressionStatement(t.callExpression(file.addHelper("inherits"), [className, superName])));
@@ -103,19 +81,25 @@ Class.prototype.run = function () {
t.inheritsComments(body[0], this.node);
if (this.closure) {
if (body.length === 1) {
// only a constructor so no need for a closure container
return constructor;
} else {
body.push(t.returnStatement(className));
return t.callExpression(
t.functionExpression(null, [], t.blockStatement(body)),
[]
);
}
var init;
if (body.length === 1) {
// only a constructor so no need for a closure container
init = constructor;
} else {
return body;
body.push(t.returnStatement(className));
init = t.callExpression(
t.functionExpression(null, closureParams, t.blockStatement(body)),
closureArgs
);
}
if (this.isStatement) {
return t.variableDeclaration("let", [
t.variableDeclarator(className, init)
]);
} else {
return init;
}
};
@@ -149,7 +133,7 @@ Class.prototype.buildBody = function () {
if (!this.hasConstructor && superName && !t.isFalsyExpression(superName)) {
constructor.body.body.push(util.template("class-super-constructor-call", {
SUPER_NAME: superName
CLASS_NAME: className
}, true));
}
@@ -157,15 +141,11 @@ Class.prototype.buildBody = function () {
var staticProps;
if (this.hasInstanceMutators) {
var protoId = util.template("prototype-identifier", {
CLASS_NAME: className
});
instanceProps = util.buildDefineProperties(this.instanceMutatorMap, protoId);
instanceProps = util.buildDefineProperties(this.instanceMutatorMap);
}
if (this.hasStaticMutators) {
staticProps = util.buildDefineProperties(this.staticMutatorMap, className);
staticProps = util.buildDefineProperties(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
@@ -190,70 +170,49 @@ Class.prototype.pushMethod = function (node) {
var methodName = node.key;
var kind = node.kind;
var mutatorMap = this.instanceMutatorMap;
if (node.static) {
this.hasStaticMutators = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceMutators = true;
}
if (kind === "") {
// method
var className = this.className;
if (!node.static) className = t.memberExpression(className, t.identifier("prototype"));
methodName = t.memberExpression(className, methodName, node.computed);
var expr = t.expressionStatement(t.assignmentExpression("=", methodName, node.value));
t.inheritsComments(expr, node);
this.body.push(expr);
} else {
// mutator
var mutatorMap = this.instanceMutatorMap;
if (node.static) {
this.hasStaticMutators = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceMutators = true;
}
util.pushMutatorMap(mutatorMap, methodName, kind, node.computed, node);
kind = "value";
}
util.pushMutatorMap(mutatorMap, methodName, kind, node.computed, node);
};
/**
* Given a `methodNode`, produce a `MemberExpression` super class reference.
* Gets a node representing the super class value of the named property.
*
* @param {Node} methodNode MethodDefinition
* @param {Node} node Identifier
* @param {Node} parent
* @example
*
* _get(Object.getPrototypeOf(CLASS.prototype), "METHOD", this)
*
* @param {Node} property
* @param {boolean} isStatic
* @param {boolean} isComputed
*
* @returns {Node}
*/
Class.prototype.superIdentifier = function (methodNode, id, parent) {
var methodName = methodNode.key;
var superName = this.superName || t.identifier("Function");
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> ClassName.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superName, t.identifier("call"));
} else {
id = superName;
// foo() { super(); }
if (!methodNode.static) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
// super.test -> ClassName.prototype.test
return t.memberExpression(superName, t.identifier("prototype"));
} else {
return superName;
}
Class.prototype.superProperty = function (property, isStatic, isComputed, thisExpression) {
return t.callExpression(
this.file.addHelper("get"),
[
t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("getPrototypeOf")),
[
isStatic ? this.className : t.memberExpression(this.className, t.identifier("prototype"))
]
),
isComputed ? property : t.literal(property.name),
thisExpression
]
);
};
/**
@@ -264,20 +223,53 @@ Class.prototype.superIdentifier = function (methodNode, id, parent) {
Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
var method = methodNode.value;
var self = this;
var self = this;
traverse(method, {
enter: function (node, parent) {
var property;
var computed;
var args;
if (t.isIdentifier(node, { name: "super" })) {
return self.superIdentifier(methodNode, node, parent);
if (!(t.isMemberExpression(parent) && !parent.computed && parent.property === node)) {
throw self.file.errorWithNode(node, "illegal use of bare super");
}
} else if (t.isCallExpression(node)) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
if (t.isIdentifier(callee, { name: "super" })) {
// super(); -> _get(Object.getPrototypeOf(ClassName), "MethodName", this).call(this);
property = methodNode.key;
computed = methodNode.computed;
args = node.arguments;
} else {
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// super.test(); -> ClassName.prototype.MethodName.call(this);
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(t.thisExpression());
// super.test(); -> _get(Object.getPrototypeOf(ClassName.prototype), "test", this).call(this);
property = callee.property;
computed = callee.computed;
args = node.arguments;
}
} else if (t.isMemberExpression(node)) {
if (!t.isIdentifier(node.object, { name: "super" })) return;
// super.name; -> _get(Object.getPrototypeOf(ClassName.prototype), "name", this);
property = node.property;
computed = node.computed;
}
if (property) {
var thisExpression = t.thisExpression();
var superProperty = self.superProperty(property, methodNode.static, computed, thisExpression);
if (args) {
return t.callExpression(
t.memberExpression(superProperty, t.identifier("call"), false),
[thisExpression].concat(args)
);
} else {
return superProperty;
}
}
}
});
@@ -290,7 +282,7 @@ Class.prototype.replaceInstanceSuperReferences = function (methodNode) {
*/
Class.prototype.pushConstructor = function (method) {
if (method.kind !== "") {
if (method.kind) {
throw this.file.errorWithNode(method, "illegal kind for constructor method");
}

View File

@@ -134,7 +134,7 @@ var pushPattern = function (opts) {
var file = opts.file;
var scope = opts.scope;
if (!t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
if (!t.isArrayExpression(parentId) && !t.isMemberExpression(parentId) && !t.isIdentifier(parentId)) {
var key = scope.generateUidBasedOnNode(parentId, file);
nodes.push(t.variableDeclaration("var", [

View File

@@ -8,7 +8,7 @@ exports.ForOfStatement = function (node, parent, file, scope) {
var stepKey = file.generateUidIdentifier("step", scope);
var stepValue = t.memberExpression(stepKey, t.identifier("value"));
if (t.isIdentifier(left)) {
if (t.isIdentifier(left) || t.isPattern(left)) {
declar = t.expressionStatement(t.assignmentExpression("=", left, stepValue));
} else if (t.isVariableDeclaration(left)) {
declar = t.variableDeclaration(left.kind, [

View File

@@ -1,3 +1,9 @@
var regenerator = require("regenerator");
exports.ast = {
before: require("regenerator").transform
before: function (ast, file) {
regenerator.transform(ast, {
includeRuntime: file.opts.includeRegenerator && "if used"
});
}
};

View File

@@ -46,7 +46,7 @@ exports.Property = function (node, parent, file, scope) {
}
};
exports.ObjectExpression = function (node, parent, file, scope) {
exports.ObjectExpression = function (node) {
var mutatorMap = {};
var hasAny = false;
@@ -62,21 +62,8 @@ exports.ObjectExpression = function (node, parent, file, scope) {
if (!hasAny) return;
if (node.properties.length) {
var objId = scope.generateUidBasedOnNode(parent, file);
return util.template("object-define-properties-closure", {
KEY: objId,
OBJECT: node,
CONTENT: util.template("object-define-properties", {
OBJECT: objId,
PROPS: util.buildDefineProperties(mutatorMap)
})
});
} else {
return util.template("object-define-properties", {
OBJECT: node,
PROPS: util.buildDefineProperties(mutatorMap)
});
}
return t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
[node, util.buildDefineProperties(mutatorMap)]
);
};

View File

@@ -0,0 +1,74 @@
var traverse = require("../../traverse");
var util = require("../../util");
var t = require("../../types");
exports.optional = true;
exports.Class = function (node) {
var superClass = node.superClass || t.identifier("Function");
var hasConstructor = false;
var body = node.body.body;
for (var i in body) {
var methodNode = body[i];
hasConstructor = hasConstructor || methodNode.key.name === "constructor";
traverse(methodNode, {
enter: function (node, parent) {
if (t.isIdentifier(node, { name: "super" })) {
return superIdentifier(superClass, methodNode, node, parent);
} else if (t.isCallExpression(node)) {
var callee = node.callee;
if (!t.isMemberExpression(callee)) return;
if (callee.object.name !== "super") return;
// super.test(); -> ClassName.prototype.MethodName.call(this);
t.appendToMemberExpression(callee, t.identifier("call"));
node.arguments.unshift(t.thisExpression());
}
}
});
}
if (node.superClass && !hasConstructor) {
body.unshift(t.methodDefinition(
t.identifier("constructor"),
util.template("class-super-constructor-call-fast", {
SUPER_NAME: superClass
})
));
}
};
var superIdentifier = function (superClass, methodNode, id, parent) {
var methodName = methodNode.key;
if (parent.property === id) {
return;
} else if (t.isCallExpression(parent, { callee: id })) {
// super(); -> ClassName.prototype.MethodName.call(this);
parent.arguments.unshift(t.thisExpression());
if (methodName.name === "constructor") {
// constructor() { super(); }
return t.memberExpression(superClass, t.identifier("call"));
} else {
id = superClass;
// foo() { super(); }
if (!methodNode.static) {
id = t.memberExpression(id, t.identifier("prototype"));
}
id = t.memberExpression(id, methodName, methodNode.computed);
return t.memberExpression(id, t.identifier("call"));
}
} else if (t.isMemberExpression(parent) && !methodNode.static) {
// super.test -> ClassName.prototype.test
return t.memberExpression(superClass, t.identifier("prototype"));
} else {
return superClass;
}
};

View File

@@ -31,8 +31,8 @@ exports.ast = {
this.skip();
return t.prependToMemberExpression(node, file._coreId);
}
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && coreHas(node)) {
// new Promise -> new _core.Promise
} else if (t.isIdentifier(node) && !t.isMemberExpression(parent) && t.isReferenced(node, parent) && node.name === "Symbol") {
// new Symbol -> new _core.Symbol
return t.memberExpression(file._coreId, node);
} else if (t.isCallExpression(node)) {
// arr[Symbol.iterator]() -> _core.$for.getIterator(arr)

View File

@@ -0,0 +1,37 @@
var util = require("../../util");
var t = require("../../types");
exports.optional = true;
exports.ForOfStatement = function (node, parent, file, scope) {
var left = node.left;
var declar, id;
if (t.isIdentifier(left) || t.isPattern(left)) {
id = left;
} else if (t.isVariableDeclaration(left)) {
id = left.declarations[0].id;
declar = t.variableDeclaration(left.kind, [
t.variableDeclarator(id)
]);
} else {
throw file.errorWithNode(left, "Unknown node type " + left.type + " in ForOfStatement");
}
var node2 = util.template("for-of-fast", {
LOOP_OBJECT: file.generateUidIdentifier("loopObject", scope),
IS_ARRAY: file.generateUidIdentifier("isArray", scope),
OBJECT: node.right,
INDEX: file.generateUidIdentifier("i", scope),
ID: id
});
t.inheritsComments(node2, node);
t.ensureBlock(node);
var block = node2.body;
if (declar) block.body.unshift(declar);
block.body = block.body.concat(node.body.body);
return node2;
};

View File

@@ -0,0 +1,6 @@
exports.MethodDefinition =
exports.Property = function (node, parent, file) {
if (node.kind === "set" && node.value.params.length !== 1) {
throw file.errorWithNode(node.value, "Setters must have only one parameter");
}
};

View File

@@ -4,15 +4,101 @@ var Scope = require("./scope");
var t = require("../types");
var _ = require("lodash");
function TraversalContext(previousContext) {
this.didSkip = false;
this.didRemove = false;
this.didStop = false;
this.didFlatten = previousContext ? previousContext.didFlatten : false;
}
TraversalContext.prototype.flatten = function () {
this.didFlatten = true;
};
TraversalContext.prototype.remove = function () {
this.didRemove = true;
this.skip();
};
TraversalContext.prototype.skip = function () {
this.didSkip = true;
};
TraversalContext.prototype.stop = function () {
this.didStop = true;
this.skip();
};
TraversalContext.prototype.maybeReplace = function (result, obj, key, node) {
if (result === false) return node;
if (result == null) return node;
var isArray = Array.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;
// 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);
}
if (isArray) {
this.flatten();
}
return node;
};
TraversalContext.prototype.visit = function (obj, key, opts, scope, parent) {
var node = obj[key];
if (!node) return;
// type is blacklisted
if (opts.blacklist && opts.blacklist.indexOf(node.type) > -1) return;
var result;
var ourScope = scope;
if (t.isScope(node)) ourScope = new Scope(node, scope);
// enter
if (opts.enter) {
result = opts.enter.call(this, node, parent, ourScope);
node = this.maybeReplace(result, obj, key, node);
if (this.didRemove) {
obj[key] = null;
this.flatten();
}
// stop traversal
if (this.didSkip) return;
}
// traverse node
traverse(node, opts, ourScope);
// exit
if (opts.exit) {
result = opts.exit.call(this, node, parent, ourScope);
node = this.maybeReplace(result, obj, key, node);
}
};
function traverse(parent, opts, scope) {
// falsy node
if (!parent) return;
// array of nodes
if (_.isArray(parent)) {
_.each(parent, function (node) {
traverse(node, opts, scope);
});
if (Array.isArray(parent)) {
for (var i = 0; i < parent.length; i++)
traverse(parent[i], opts, scope);
return;
}
@@ -21,99 +107,21 @@ function traverse(parent, opts, scope) {
if (!keys) return;
opts = opts || {};
var context = null;
var stopped = false;
for (var i in keys) {
var key = keys[i];
for (var j = 0; j < keys.length; j++) {
var key = keys[j];
var nodes = parent[key];
if (!nodes) continue;
var flatten = false;
var handle = function (obj, key) {
var node = obj[key];
if (!node) return;
// type is blacklisted
if (opts.blacklist && opts.blacklist.indexOf(node.type) > -1) return;
// replace node
var maybeReplace = function (result) {
if (result === false) return;
if (result == null) return;
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) flatten = true;
// 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 skipped = false;
var removed = false;
var context = {
stop: function () {
skipped = stopped = true;
},
skip: function () {
skipped = true;
},
remove: function () {
this.skip();
removed = true;
}
};
//
var ourScope = scope;
if (t.isScope(node)) ourScope = new Scope(node, scope);
// enter
if (opts.enter) {
var result = opts.enter.call(context, node, parent, ourScope);
maybeReplace(result);
if (removed) {
obj[key] = null;
flatten = true;
}
// stop iteration
if (skipped) return;
if (Array.isArray(nodes)) {
for (var k = 0; k < nodes.length; k++) {
context = new TraversalContext(context);
context.visit(nodes, k, opts, scope, parent);
if (context.didStop) return;
}
// traverse node
traverse(node, opts, ourScope);
// exit
if (opts.exit) {
maybeReplace(opts.exit.call(context, node, parent, ourScope));
}
};
if (_.isArray(nodes)) {
for (i in nodes) {
handle(nodes, i);
if (stopped) return;
}
if (flatten) {
if (context && context.didFlatten) {
parent[key] = _.flatten(parent[key]);
if (key === "body") {
@@ -122,8 +130,9 @@ function traverse(parent, opts, scope) {
}
}
} else {
handle(parent, key);
if (stopped) return;
context = new TraversalContext(context);
context.visit(parent, key, opts, scope, parent);
if (context.didStop) return;
}
}
}

View File

@@ -24,7 +24,13 @@ function Scope(block, parent) {
}
var vars = require("jshint/src/vars");
Scope.defaultDeclarations = _.flatten([vars.newEcmaIdentifiers, vars.node, vars.ecmaIdentifiers, vars.reservedVars].map(_.keys));
Scope.defaultDeclarations = _.flatten([
vars.newEcmaIdentifiers,
vars.node,
vars.ecmaIdentifiers,
vars.reservedVars
].map(_.keys));
Scope.add = function (node, references) {
if (!node) return;

View File

@@ -16,6 +16,7 @@
"Literal": ["value"],
"LogicalExpression": ["operator", "left", "right"],
"MemberExpression": ["object", "property", "computed"],
"MethodDefinition": ["key", "value", "computed", "kind"],
"NewExpression": ["callee", "arguments"],
"ObjectExpression": ["properties"],
"Program": ["body"],

View File

@@ -320,7 +320,11 @@ t.toBlock = function (node, parent) {
return node;
}
if (!_.isArray(node)) {
if (t.isEmptyStatement(node)) {
node = [];
}
if (!Array.isArray(node)) {
if (!t.isStatement(node)) {
if (t.isFunction(parent)) {
node = t.returnStatement(node);

View File

@@ -39,7 +39,7 @@ exports.list = function (val) {
exports.regexify = function (val) {
if (!val) return new RegExp(/.^/);
if (_.isArray(val)) val = val.join("|");
if (Array.isArray(val)) val = val.join("|");
if (_.isString(val)) return new RegExp(val);
if (_.isRegExp(val)) return val;
throw new TypeError("illegal type for regexify");
@@ -48,7 +48,7 @@ exports.regexify = function (val) {
exports.arrayify = function (val) {
if (!val) return [];
if (_.isString(val)) return exports.list(val);
if (_.isArray(val)) return val;
if (Array.isArray(val)) return val;
throw new TypeError("illegal type for arrayify");
};
@@ -101,7 +101,12 @@ exports.buildDefineProperties = function (mutatorMap) {
var propNode = t.property("init", map._key, mapNode, map._computed);
if (!map.get && !map.set) {
map.writable = t.literal(true);
}
map.enumerable = t.literal(true);
map.configurable = t.literal(true);
_.each(map, function (node, key) {
if (key[0] === "_") return;
@@ -188,7 +193,13 @@ exports.codeFrame = function (lines, lineNumber, colNumber) {
exports.repeat = function (width, cha) {
cha = cha || " ";
return new Array(width + 1).join(cha);
var result = "";
for (var i = 0; i < width; i++) {
result += cha;
}
return result;
};
exports.normaliseAst = function (ast, comments, tokens) {

View File

@@ -1,7 +1,7 @@
{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "2.8.2",
"version": "2.10.1",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"homepage": "https://github.com/6to5/6to5",
"repository": {
@@ -39,11 +39,11 @@
"test": "make test"
},
"dependencies": {
"acorn-6to5": "0.11.1-11",
"acorn-6to5": "0.11.1-13",
"ast-types": "~0.6.1",
"chokidar": "0.11.1",
"commander": "2.5.0",
"core-js": "^0.4.1",
"core-js": "^0.4.4",
"estraverse": "1.8.0",
"esutils": "1.1.6",
"esvalid": "^1.1.0",

View File

@@ -12,7 +12,7 @@ suite("browserify", function() {
assert.ok(bundle.length, "bundle output code");
// ensure that the code runs without throwing an exception
vm.runInNewContext(bundle, {});
vm.runInNewContext("var global = this;\n" + bundle, {});
done();
})
})

View File

@@ -1,5 +1,3 @@
if (!process.env.ALL_6TO5_TESTS) return;
require("./_transformation-helper")({
name: "esnext"
});

View File

@@ -1,9 +1,11 @@
class Animal {
class Base {
get sound() {
return 'I am a ' + this.type + '.';
}
}
class Animal extends Base {}
class Cat extends Animal {
get type() { return 'cat'; }

View File

@@ -1,2 +1,3 @@
++i;
i++;
(foo++).test();

View File

@@ -1,2 +1,3 @@
++i;
i++;
(foo++).test();

View File

@@ -3,7 +3,6 @@ class Test extends Foo {
woops.super.test();
super();
super.test();
foob(super);
super(...arguments);
super("test", ...arguments);

View File

@@ -1,6 +1,33 @@
"use strict";
var _slice = Array.prototype.slice;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
@@ -16,37 +43,47 @@ var _inherits = function (child, parent) {
if (parent) child.__proto__ = parent;
};
var Test = (function () {
var _Foo = Foo;
var Test = (function (Foo) {
var Test = function Test() {
var _Foo$prototype$test, _Foo$prototype$test2;
var _get2, _get3, _get4, _get5;
woops["super"].test();
_Foo.call(this);
_Foo.prototype.test.call(this);
foob(_Foo);
_get(Object.getPrototypeOf(Test.prototype), "constructor", this).call(this);
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
_Foo.call.apply(_Foo, [this].concat(_slice.call(arguments)));
_Foo.call.apply(_Foo, [this, "test"].concat(_slice.call(arguments)));
(_get2 = _get(Object.getPrototypeOf(Test.prototype), "constructor", this)).call.apply(_get2, [this].concat(_slice.call(arguments)));
(_get3 = _get(Object.getPrototypeOf(Test.prototype), "constructor", this)).call.apply(_get3, [this, "test"].concat(_slice.call(arguments)));
(_Foo$prototype$test = _Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test2 = _Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
(_get4 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get4, [this].concat(_slice.call(arguments)));
(_get5 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get5, [this, "test"].concat(_slice.call(arguments)));
};
_inherits(Test, _Foo);
_inherits(Test, Foo);
Test.prototype.test = function () {
var _Foo$prototype$test3, _Foo$prototype$test4;
_Foo.prototype.test.call(this);
(_Foo$prototype$test3 = _Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test4 = _Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
};
Test.foo = function () {
var _Foo$foo, _Foo$foo2;
_Foo.foo.call(this);
(_Foo$foo = _Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
(_Foo$foo2 = _Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
};
_prototypeProperties(Test, {
foo: {
value: function () {
var _get6, _get7;
_get(Object.getPrototypeOf(Test), "foo", this).call(this);
(_get6 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get6, [this].concat(_slice.call(arguments)));
(_get7 = _get(Object.getPrototypeOf(Test), "foo", this)).call.apply(_get7, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
}, {
test: {
value: function () {
var _get8, _get9;
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
(_get8 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get8, [this].concat(_slice.call(arguments)));
(_get9 = _get(Object.getPrototypeOf(Test.prototype), "test", this)).call.apply(_get9, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();
})(Foo);

View File

@@ -1,5 +1,27 @@
"use strict";
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
@@ -15,14 +37,13 @@ var _inherits = function (child, parent) {
if (parent) child.__proto__ = parent;
};
var Test = (function () {
var _Foo = Foo;
var Test = (function (Foo) {
var Test = function Test() {
_Foo.prototype.test;
_Foo.prototype.test.whatever;
_get(Object.getPrototypeOf(Test.prototype), "test", this);
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever;
};
_inherits(Test, _Foo);
_inherits(Test, Foo);
return Test;
})();
})(Foo);

View File

@@ -0,0 +1,5 @@
class Test {
constructor() {
console.log(super);
}
}

View File

@@ -0,0 +1,3 @@
{
"throws": "illegal use of bare super"
}

View File

@@ -1,5 +1,32 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
@@ -15,18 +42,24 @@ var _inherits = function (child, parent) {
if (parent) child.__proto__ = parent;
};
var Test = (function () {
var _Foo = Foo;
var Test = (function (Foo) {
var Test = function Test() {
_Foo.prototype.test.whatever();
_Foo.prototype.test.call(this);
_get(Object.getPrototypeOf(Test.prototype), "test", this).whatever();
_get(Object.getPrototypeOf(Test.prototype), "test", this).call(this);
};
_inherits(Test, _Foo);
_inherits(Test, Foo);
Test.test = function () {
return _Foo.wow.call(this);
};
_prototypeProperties(Test, {
test: {
value: function () {
return _get(Object.getPrototypeOf(Test), "wow", this).call(this);
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();
})(Foo);

View File

@@ -19,13 +19,12 @@ var Test = function Test() {
this.state = "test";
};
var Foo = (function () {
var _Bar = Bar;
var Foo = (function (Bar) {
var Foo = function Foo() {
this.state = "test";
};
_inherits(Foo, _Bar);
_inherits(Foo, Bar);
return Foo;
})();
})(Bar);

View File

@@ -5,16 +5,21 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
set: function (val) {
this._test = val;
},
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -5,13 +5,18 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
get: function () {
return 5 + 5;
},
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -1,7 +1,23 @@
"use strict";
var Test = function Test() {};
Test.prototype.test = function () {
return 5 + 5;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
value: function () {
return 5 + 5;
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -5,13 +5,18 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
test: {
set: function (val) {
this._test = val;
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
test: {
set: function (val) {
this._test = val;
},
enumerable: true,
configurable: true
}
});
return Test;
})();

View File

@@ -1,5 +1,10 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var BaseView = function BaseView() {
this.autoRender = true;
};
@@ -11,9 +16,16 @@ var BaseView = function () {
var BaseView = (function () {
var _class2 = function () {};
_class2.prototype.foo = function () {
this.autoRender = true;
};
_prototypeProperties(_class2, null, {
foo: {
value: function () {
this.autoRender = true;
},
writable: true,
enumerable: true,
configurable: true
}
});
return _class2;
})();

View File

@@ -5,14 +5,23 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var A = function A() {};
var A = (function () {
var A = function A() {};
A.a = function () {};
_prototypeProperties(A, {
a: {
value: function () {},
writable: true,
enumerable: true,
configurable: true
},
b: {
get: function () {},
set: function (b) {},
enumerable: true,
configurable: true
}
});
_prototypeProperties(A, {
b: {
get: function () {},
set: function (b) {},
enumerable: true
}
});
return A;
})();

View File

@@ -15,28 +15,26 @@ var _inherits = function (child, parent) {
if (parent) child.__proto__ = parent;
};
var BaseController = (function () {
var _Chaplin$Controller = Chaplin.Controller;
var BaseController = (function (_Chaplin$Controller) {
var BaseController = function BaseController() {
if (_Chaplin$Controller !== null) {
_Chaplin$Controller.apply(this, arguments);
if (Object.getPrototypeOf(BaseController) !== null) {
Object.getPrototypeOf(BaseController).apply(this, arguments);
}
};
_inherits(BaseController, _Chaplin$Controller);
return BaseController;
})();
})(Chaplin.Controller);
var BaseController2 = (function () {
var _Chaplin$Controller$Another = Chaplin.Controller.Another;
var BaseController2 = (function (_Chaplin$Controller$Another) {
var BaseController2 = function BaseController2() {
if (_Chaplin$Controller$Another !== null) {
_Chaplin$Controller$Another.apply(this, arguments);
if (Object.getPrototypeOf(BaseController2) !== null) {
Object.getPrototypeOf(BaseController2).apply(this, arguments);
}
};
_inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2;
})();
})(Chaplin.Controller.Another);

View File

@@ -15,15 +15,14 @@ var _inherits = function (child, parent) {
if (parent) child.__proto__ = parent;
};
var Test = (function () {
var _Foo = Foo;
var Test = (function (Foo) {
var Test = function Test() {
if (_Foo !== null) {
_Foo.apply(this, arguments);
if (Object.getPrototypeOf(Test) !== null) {
Object.getPrototypeOf(Test).apply(this, arguments);
}
};
_inherits(Test, _Foo);
_inherits(Test, Foo);
return Test;
})();
})(Foo);

View File

@@ -1,5 +1,28 @@
"use strict";
var Test = function Test() {
Function.prototype.hasOwnProperty.call(this, "test");
var _get = function get(object, property, receiver) {
var desc = Object.getOwnPropertyDescriptor(object, property);
if (desc === undefined) {
var parent = Object.getPrototypeOf(object);
if (parent === null) {
return undefined;
} else {
return get(parent, property, receiver);
}
} else if ("value" in desc && desc.writable) {
return desc.value;
} else {
var getter = desc.get;
if (getter === undefined) {
return undefined;
}
return getter.call(receiver);
}
};
var Test = function Test() {
_get(Object.getPrototypeOf(Test.prototype), "hasOwnProperty", this).call(this, "test");
};

View File

@@ -1,38 +1,18 @@
"use strict";
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 = _slicedToArray(_ref, 2);
var a = _ref[0];
var b = _ref[1];
var _ref2 = [3, 4];
var a = _ref2[0];
var b = _ref2[1];
var _ref3 = [3, 4];
var c = _ref2[0];
var d = _ref2[1];
var _ref3 = { e: 5, f: 6 };
var _ref3 = _slicedToArray(_ref3, 2);
var e = _ref3.e;
var f = _ref3.f;
var _ref4 = { a: 7, b: 8 };
var c = _ref3[0];
var d = _ref3[1];
var _ref4 = { e: 5, f: 6 };
var e = _ref4.e;
var f = _ref4.f;
var _ref5 = { a: 7, b: 8 };
var g = _ref5.a;
var h = _ref5.b;
var g = _ref4.a;
var h = _ref4.b;

View File

@@ -18,13 +18,11 @@ var _slicedToArray = function (arr, i) {
var _ref = ["hello", [", ", "junk"], ["world"]];
var _ref2 = _slicedToArray(_ref, 4);
var a = _ref[0];
var _ref$1 = _slicedToArray(_ref[1], 1);
var a = _ref2[0];
var _ref2$1 = _slicedToArray(_ref2[1], 1);
var b = _ref$1[0];
var _ref$2 = _slicedToArray(_ref[2], 1);
var b = _ref2$1[0];
var _ref2$2 = _slicedToArray(_ref2[2], 1);
var c = _ref2$2[0];
var d = _ref2[3];
var c = _ref$2[0];
var d = _ref[3];

View File

@@ -18,13 +18,11 @@ var _slicedToArray = function (arr, i) {
var _ref = ["foo", "hello", [", ", "junk"], ["world"]];
var _ref2 = _slicedToArray(_ref, 5);
var a = _ref[1];
var _ref$2 = _slicedToArray(_ref[2], 1);
var a = _ref2[1];
var _ref2$2 = _slicedToArray(_ref2[2], 1);
var b = _ref$2[0];
var _ref$3 = _slicedToArray(_ref[3], 1);
var b = _ref2$2[0];
var _ref2$3 = _slicedToArray(_ref2[3], 1);
var c = _ref2$3[0];
var d = _ref2[4];
var c = _ref$3[0];
var d = _ref[4];

View File

@@ -7,15 +7,17 @@ define(["exports", "foo"], function (exports, _foo) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -7,15 +7,17 @@ define(["exports", "foo"], function (exports, _foo) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -6,15 +6,17 @@ var _interopRequireWildcard = function (obj) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(require("foo")));
_defaults(exports, _interopRequireWildcard(require("foo")));
exports.foo = require("foo").foo;
exports.foo = require("foo").foo;

View File

@@ -6,15 +6,17 @@ var _interopRequireWildcard = function (obj) {
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(require("foo")));
_defaults(exports, _interopRequireWildcard(require("foo")));
exports.foo = require("foo").foo;
exports.foo = require("foo").foo;

View File

@@ -13,15 +13,17 @@
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -13,15 +13,17 @@
};
};
var _exportsWildcard = function (obj) {
for (var i in obj) {
if (exports[i] !== undefined) {
exports[i] = obj[i];
var _defaults = function (obj, defaults) {
for (var key in defaults) {
if (obj[key] === undefined) {
obj[key] = defaults[key];
}
}
return obj;
};
_exportsWildcard(_interopRequireWildcard(_foo));
_defaults(exports, _interopRequireWildcard(_foo));
exports.foo = _foo.foo;
exports.foo = _foo.foo;

View File

@@ -18,7 +18,8 @@ var obj = Object.defineProperties({}, _defineProperty({}, x, {
set: function (value) {
valueSet = value;
},
enumerable: true
enumerable: true,
configurable: true
}));
obj.y = "foo";
obj.y === 1 && valueSet === "foo";

View File

@@ -8,6 +8,7 @@ var obj = Object.defineProperties({}, {
set: function (value) {
this._foo = value;
},
enumerable: true
enumerable: true,
configurable: true
}
});

View File

@@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, {
get: function () {
return 5 + 5;
},
enumerable: true
enumerable: true,
configurable: true
}
});

View File

@@ -5,6 +5,7 @@ var obj = Object.defineProperties({}, {
set: function (value) {
this._foo = value;
},
enumerable: true
enumerable: true,
configurable: true
}
});

View File

@@ -0,0 +1,25 @@
class Test extends Foo {
constructor() {
woops.super.test();
super();
super.test();
super(...arguments);
super("test", ...arguments);
super.test(...arguments);
super.test("test", ...arguments);
}
test() {
super();
super(...arguments);
super("test", ...arguments);
}
static foo() {
super();
super(...arguments);
super("test", ...arguments);
}
}

View File

@@ -0,0 +1,67 @@
"use strict";
var _slice = Array.prototype.slice;
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
};
var Test = (function (Foo) {
var Test = function Test() {
var _Foo$prototype$test, _Foo$prototype$test2;
woops["super"].test();
Foo.call(this);
Foo.prototype.test.call(this);
Foo.call.apply(Foo, [this].concat(_slice.call(arguments)));
Foo.call.apply(Foo, [this, "test"].concat(_slice.call(arguments)));
(_Foo$prototype$test = Foo.prototype.test).call.apply(_Foo$prototype$test, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test2 = Foo.prototype.test).call.apply(_Foo$prototype$test2, [this, "test"].concat(_slice.call(arguments)));
};
_inherits(Test, Foo);
_prototypeProperties(Test, {
foo: {
value: function () {
var _Foo$foo, _Foo$foo2;
Foo.foo.call(this);
(_Foo$foo = Foo.foo).call.apply(_Foo$foo, [this].concat(_slice.call(arguments)));
(_Foo$foo2 = Foo.foo).call.apply(_Foo$foo2, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
}, {
test: {
value: function () {
var _Foo$prototype$test3, _Foo$prototype$test4;
Foo.prototype.test.call(this);
(_Foo$prototype$test3 = Foo.prototype.test).call.apply(_Foo$prototype$test3, [this].concat(_slice.call(arguments)));
(_Foo$prototype$test4 = Foo.prototype.test).call.apply(_Foo$prototype$test4, [this, "test"].concat(_slice.call(arguments)));
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -0,0 +1,6 @@
class Test extends Foo {
constructor() {
super.test;
super.test.whatever;
}
}

View File

@@ -0,0 +1,27 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
};
var Test = (function (Foo) {
var Test = function Test() {
Foo.prototype.test;
Foo.prototype.test.whatever;
};
_inherits(Test, Foo);
return Test;
})(Foo);

View File

@@ -0,0 +1,10 @@
class Test extends Foo {
constructor() {
super.test.whatever();
super.test();
}
static test() {
return super.wow();
}
}

View File

@@ -0,0 +1,43 @@
"use strict";
var _prototypeProperties = function (child, staticProps, instanceProps) {
if (staticProps) Object.defineProperties(child, staticProps);
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
};
var Test = (function (Foo) {
var Test = function Test() {
Foo.prototype.test.whatever();
Foo.prototype.test.call(this);
};
_inherits(Test, Foo);
_prototypeProperties(Test, {
test: {
value: function () {
return Foo.wow.call(this);
},
writable: true,
enumerable: true,
configurable: true
}
});
return Test;
})(Foo);

View File

@@ -0,0 +1,3 @@
{
"optional": ["classesFastSuper"]
}

View File

@@ -0,0 +1,7 @@
class BaseController extends Chaplin.Controller {
}
class BaseController2 extends Chaplin.Controller.Another {
}

View File

@@ -0,0 +1,40 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
};
var BaseController = (function (_Chaplin$Controller) {
var BaseController = function BaseController() {
if (Chaplin.Controller != null) {
Chaplin.Controller.apply(this, arguments);
}
};
_inherits(BaseController, _Chaplin$Controller);
return BaseController;
})(Chaplin.Controller);
var BaseController2 = (function (_Chaplin$Controller$Another) {
var BaseController2 = function BaseController2() {
if (Chaplin.Controller.Another != null) {
Chaplin.Controller.Another.apply(this, arguments);
}
};
_inherits(BaseController2, _Chaplin$Controller$Another);
return BaseController2;
})(Chaplin.Controller.Another);

View File

@@ -0,0 +1 @@
class Test extends Foo { }

View File

@@ -0,0 +1,28 @@
"use strict";
var _inherits = function (child, parent) {
if (typeof parent !== "function" && parent !== null) {
throw new TypeError("Super expression must either be null or a function, not " + typeof parent);
}
child.prototype = Object.create(parent && parent.prototype, {
constructor: {
value: child,
enumerable: false,
writable: true,
configurable: true
}
});
if (parent) child.__proto__ = parent;
};
var Test = (function (Foo) {
var Test = function Test() {
if (Foo != null) {
Foo.apply(this, arguments);
}
};
_inherits(Test, Foo);
return Test;
})(Foo);

View File

@@ -0,0 +1,5 @@
class Test {
constructor() {
super.hasOwnProperty("test");
}
}

View File

@@ -0,0 +1,5 @@
"use strict";
var Test = function Test() {
Function.prototype.hasOwnProperty.call(this, "test");
};

View File

@@ -24,13 +24,11 @@ var _core = _interopRequire(require("core-js/library"));
var _ref = ["hello", [", ", "junk"], ["world"]];
var _ref2 = _slicedToArray(_ref, 4);
var a = _ref[0];
var _ref$1 = _slicedToArray(_ref[1], 1);
var a = _ref2[0];
var _ref2$1 = _slicedToArray(_ref2[1], 1);
var b = _ref$1[0];
var _ref$2 = _slicedToArray(_ref[2], 1);
var b = _ref2$1[0];
var _ref2$2 = _slicedToArray(_ref2[2], 1);
var c = _ref2$2[0];
var d = _ref2[3];
var c = _ref$2[0];
var d = _ref[3];

View File

@@ -0,0 +1 @@
obj.constructor === Object;

View File

@@ -0,0 +1,9 @@
"use strict";
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj);
};
var _core = _interopRequire(require("core-js/library"));
obj.constructor === Object;

View File

@@ -0,0 +1,2 @@
Symbol("test");
Symbol();

View File

@@ -0,0 +1,10 @@
"use strict";
var _interopRequire = function (obj) {
return obj && (obj["default"] || obj);
};
var _core = _interopRequire(require("core-js/library"));
_core.Symbol("test");
_core.Symbol();

View File

@@ -25,15 +25,14 @@ var _inherits = function (child, parent) {
if (parent) _defaults(child, parent);
};
var Foo = (function () {
var _Bar = Bar;
var Foo = (function (Bar) {
var Foo = function Foo() {
if (_Bar !== null) {
_Bar.apply(this, arguments);
if (Object.getPrototypeOf(Foo) !== null) {
Object.getPrototypeOf(Foo).apply(this, arguments);
}
};
_inherits(Foo, _Bar);
_inherits(Foo, Bar);
return Foo;
})();
})(Bar);

View File

@@ -14,32 +14,40 @@ var _defineProperty = function (obj, key, value) {
});
};
var Foo = function Foo() {};
var Foo = (function () {
var Foo = function Foo() {};
_prototypeProperties(Foo, null, _defineProperty({
bar: {
_prototypeProperties(Foo, null, _defineProperty({
bar: {
get: function () {
return _defineProperty(this, "bar", complex()).bar;
},
enumerable: true,
configurable: true
}
}, bar, {
get: function () {
return _defineProperty(this, "bar", complex()).bar;
return _defineProperty(this, bar, complex())[bar];
},
enumerable: true
}
}, bar, {
get: function () {
return _defineProperty(this, bar, complex())[bar];
},
enumerable: true
}));
enumerable: true,
configurable: true
}));
return Foo;
})();
var foo = Object.defineProperties({}, _defineProperty({
bar: {
get: function () {
return _defineProperty(this, "bar", complex()).bar;
},
enumerable: true
enumerable: true,
configurable: true
}
}, bar, {
get: function () {
return _defineProperty(this, bar, complex())[bar];
},
enumerable: true
enumerable: true,
configurable: true
}));

View File

@@ -5,16 +5,21 @@ var _prototypeProperties = function (child, staticProps, instanceProps) {
if (instanceProps) Object.defineProperties(child.prototype, instanceProps);
};
var Test = function Test() {};
var Test = (function () {
var Test = function Test() {};
_prototypeProperties(Test, null, {
bar: {
get: function () {
throw new Error("wow");
},
enumerable: true
}
});
_prototypeProperties(Test, null, {
bar: {
get: function () {
throw new Error("wow");
},
enumerable: true,
configurable: true
}
});
return Test;
})();
var test = new Test();
test.bar;

View File

@@ -4,7 +4,7 @@
"column": 10
},
"generated": {
"line": 13,
"column": 13
"line": 14,
"column": 15
}
}]

View File

@@ -0,0 +1,5 @@
class Foo {
set bar() {
}
}

View File

@@ -0,0 +1,5 @@
class Foo {
set bar(foo, bar) {
}
}

View File

@@ -0,0 +1,5 @@
var obj = {
set bar() {
}
};

View File

@@ -0,0 +1,5 @@
var obj = {
set bar(foo, bar) {
}
};

View File

@@ -0,0 +1,3 @@
{
"throws": "Setters must have only one parameter"
}