add ludicrous transformer

This commit is contained in:
Sebastian McKenzie 2015-04-01 23:23:09 +11:00
parent 658164a0d2
commit 563a427b69
4 changed files with 31 additions and 6 deletions

View File

@ -0,0 +1 @@
Object(RIGHT)[LEFT] !== undefined;

View File

@ -1,5 +0,0 @@
import * as t from "../../../types";
export var metadata = {
optional: true
};

View File

@ -101,8 +101,8 @@ export default {
"es7.doExpressions": require("./es7/do-expressions"),
"es6.spec.symbols": require("./es6/spec.symbols"),
ludicrous: require("./other/ludicrous"),
"spec.undefinedToVoid": require("./spec/undefined-to-void"),
"es1.ludicrous": require("./es1/ludicrous"),
_strict: require("./internal/strict"),
_moduleFormatter: require("./internal/module-formatter"),

View File

@ -0,0 +1,29 @@
import * as t from "../../../types";
import * as util from "../../../util";
export var metadata = {
optional: true
};
export function BinaryExpression(node) {
if (node.operator === "in") {
return util.template("ludicrous-in", {
LEFT: node.left,
RIGHT: node.right
});
}
}
export function Property(node) {
var key = node.key;
if (t.isLiteral(key) && typeof key.value === "number") {
key.value = "" + key.value;
}
}
export function Literal(node) {
if (node.regex) {
node.regex.pattern = "foobar";
node.regex.flags = "";
}
}