babel-plugin-minify-type-constructors
Advanced tools
Comparing version 0.5.0-alpha.55276695 to 0.5.0-alpha.18dcfe13
"use strict"; | ||
function replaceArray(t, path) { | ||
var node = path.node; // arguments is taken :( | ||
const node = path.node; // arguments is taken :( | ||
var constructorArgs = path.get("arguments"); | ||
const constructorArgs = path.get("arguments"); | ||
@@ -15,4 +15,4 @@ if (t.isIdentifier(node.callee, { | ||
} else if (constructorArgs.length === 1) { | ||
var arg = constructorArgs[0]; | ||
var result = arg.evaluate(); | ||
const arg = constructorArgs[0]; | ||
const result = arg.evaluate(); | ||
@@ -32,3 +32,3 @@ if (result.confident) { | ||
} else { | ||
var transformables = ["ArrayExpression", "ObjectExpression", "FunctionExpression", "ArrowFunctionExpression", "ClassExpression"]; | ||
const transformables = ["ArrayExpression", "ObjectExpression", "FunctionExpression", "ArrowFunctionExpression", "ClassExpression"]; | ||
@@ -60,3 +60,3 @@ if (transformables.indexOf(arg.node.type) !== -1) { | ||
function replaceObject(t, path) { | ||
var node = path.node; | ||
const node = path.node; | ||
@@ -66,6 +66,6 @@ if (t.isIdentifier(node.callee, { | ||
}) && !path.scope.getBinding("Object")) { | ||
var isVoid0 = require("babel-helper-is-void-0")(t); | ||
const isVoid0 = require("babel-helper-is-void-0")(t); | ||
var arg = node.arguments[0]; | ||
var binding = arg && t.isIdentifier(arg) && path.scope.getBinding(arg.name); // Object() -> {} | ||
const arg = node.arguments[0]; | ||
const binding = arg && t.isIdentifier(arg) && path.scope.getBinding(arg.name); // Object() -> {} | ||
@@ -90,15 +90,9 @@ if (node.arguments.length === 0) { | ||
function defaults() { | ||
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
_ref$boolean = _ref.boolean, | ||
boolean = _ref$boolean === void 0 ? true : _ref$boolean, | ||
_ref$number = _ref.number, | ||
number = _ref$number === void 0 ? true : _ref$number, | ||
_ref$string = _ref.string, | ||
string = _ref$string === void 0 ? true : _ref$string, | ||
_ref$array = _ref.array, | ||
array = _ref$array === void 0 ? true : _ref$array, | ||
_ref$object = _ref.object, | ||
object = _ref$object === void 0 ? true : _ref$object; | ||
function defaults({ | ||
boolean = true, | ||
number = true, | ||
string = true, | ||
array = true, | ||
object = true | ||
} = {}) { | ||
return { | ||
@@ -113,4 +107,5 @@ boolean, | ||
module.exports = function (_ref2) { | ||
var t = _ref2.types; | ||
module.exports = function ({ | ||
types: t | ||
}) { | ||
return { | ||
@@ -120,4 +115,4 @@ name: "minify-type-constructors", | ||
CallExpression(path) { | ||
var node = path.node; | ||
var opts = defaults(this.opts); // Boolean(foo) -> !!foo | ||
const node = path.node; | ||
const opts = defaults(this.opts); // Boolean(foo) -> !!foo | ||
@@ -159,3 +154,3 @@ if (opts.boolean && t.isIdentifier(node.callee, { | ||
NewExpression(path) { | ||
var opts = defaults(this.opts); // new Array() -> [] | ||
const opts = defaults(this.opts); // new Array() -> [] | ||
@@ -162,0 +157,0 @@ if (opts.array && replaceArray(t, path)) { |
{ | ||
"name": "babel-plugin-minify-type-constructors", | ||
"version": "0.5.0-alpha.55276695", | ||
"version": "0.5.0-alpha.18dcfe13", | ||
"description": "", | ||
@@ -15,4 +15,4 @@ "keywords": [ | ||
"dependencies": { | ||
"babel-helper-is-void-0": "^0.5.0-alpha.55276695" | ||
"babel-helper-is-void-0": "^0.5.0-alpha.18dcfe13" | ||
} | ||
} |
@@ -32,3 +32,3 @@ # babel-plugin-minify-type-constructors | ||
```sh | ||
npm install babel-plugin-minify-type-constructors | ||
npm install babel-plugin-minify-type-constructors --save-dev | ||
``` | ||
@@ -35,0 +35,0 @@ |
6382
132