add ludicrous transformer
This commit is contained in:
parent
658164a0d2
commit
563a427b69
1
src/babel/transformation/templates/ludicrous-in.js
Normal file
1
src/babel/transformation/templates/ludicrous-in.js
Normal file
@ -0,0 +1 @@
|
||||
Object(RIGHT)[LEFT] !== undefined;
|
||||
@ -1,5 +0,0 @@
|
||||
import * as t from "../../../types";
|
||||
|
||||
export var metadata = {
|
||||
optional: true
|
||||
};
|
||||
@ -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"),
|
||||
|
||||
29
src/babel/transformation/transformers/other/ludicrous.js
Normal file
29
src/babel/transformation/transformers/other/ludicrous.js
Normal 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 = "";
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user