@babel/plugin-transform-spread
Advanced tools
Comparing version 7.0.0-beta.43 to 7.0.0-beta.44
@@ -9,5 +9,5 @@ "use strict"; | ||
function _helperPluginUtils() { | ||
const data = require("@babel/helper-plugin-utils"); | ||
var data = require("@babel/helper-plugin-utils"); | ||
_helperPluginUtils = function () { | ||
_helperPluginUtils = function _helperPluginUtils() { | ||
return data; | ||
@@ -20,5 +20,5 @@ }; | ||
function _core() { | ||
const data = require("@babel/core"); | ||
var data = require("@babel/core"); | ||
_core = function () { | ||
_core = function _core() { | ||
return data; | ||
@@ -30,7 +30,5 @@ }; | ||
var _default = (0, _helperPluginUtils().declare)((api, options) => { | ||
var _default = (0, _helperPluginUtils().declare)(function (api, options) { | ||
api.assertVersion(7); | ||
const { | ||
loose | ||
} = options; | ||
var loose = options.loose; | ||
@@ -48,3 +46,3 @@ function getSpreadLiteral(spread, scope) { | ||
function hasSpread(nodes) { | ||
for (let i = 0; i < nodes.length; i++) { | ||
for (var i = 0; i < nodes.length; i++) { | ||
if (_core().types.isSpreadElement(nodes[i])) { | ||
@@ -65,6 +63,19 @@ return true; | ||
function build(props, scope) { | ||
const nodes = []; | ||
let _props = []; | ||
var nodes = []; | ||
var _props = []; | ||
for (const prop of props) { | ||
for (var _iterator = props, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
var prop = _ref; | ||
if (_core().types.isSpreadElement(prop)) { | ||
@@ -84,11 +95,9 @@ _props = push(_props, nodes); | ||
visitor: { | ||
ArrayExpression(path, state) { | ||
const { | ||
node, | ||
scope | ||
} = path; | ||
const elements = node.elements; | ||
ArrayExpression: function ArrayExpression(path, state) { | ||
var node = path.node, | ||
scope = path.scope; | ||
var elements = node.elements; | ||
if (!hasSpread(elements)) return; | ||
const nodes = build(elements, scope, state); | ||
const first = nodes.shift(); | ||
var nodes = build(elements, scope, state); | ||
var first = nodes.shift(); | ||
@@ -102,15 +111,12 @@ if (nodes.length === 0 && first !== elements[0].argument) { | ||
}, | ||
CallExpression(path, state) { | ||
const { | ||
node, | ||
scope | ||
} = path; | ||
const args = node.arguments; | ||
CallExpression: function CallExpression(path, state) { | ||
var node = path.node, | ||
scope = path.scope; | ||
var args = node.arguments; | ||
if (!hasSpread(args)) return; | ||
const calleePath = path.get("callee"); | ||
var calleePath = path.get("callee"); | ||
if (calleePath.isSuper()) return; | ||
let contextLiteral = scope.buildUndefinedNode(); | ||
var contextLiteral = scope.buildUndefinedNode(); | ||
node.arguments = []; | ||
let nodes; | ||
var nodes; | ||
@@ -123,3 +129,3 @@ if (args.length === 1 && args[0].argument.name === "arguments") { | ||
const first = nodes.shift(); | ||
var first = nodes.shift(); | ||
@@ -132,6 +138,6 @@ if (nodes.length) { | ||
const callee = node.callee; | ||
var callee = node.callee; | ||
if (calleePath.isMemberExpression()) { | ||
const temp = scope.maybeGenerateMemoised(callee.object); | ||
var temp = scope.maybeGenerateMemoised(callee.object); | ||
@@ -156,13 +162,10 @@ if (temp) { | ||
}, | ||
NewExpression(path, state) { | ||
const { | ||
node, | ||
scope | ||
} = path; | ||
let args = node.arguments; | ||
NewExpression: function NewExpression(path, state) { | ||
var node = path.node, | ||
scope = path.scope; | ||
var args = node.arguments; | ||
if (!hasSpread(args)) return; | ||
const nodes = build(args, scope, state); | ||
var nodes = build(args, scope, state); | ||
const context = _core().types.arrayExpression([_core().types.nullLiteral()]); | ||
var context = _core().types.arrayExpression([_core().types.nullLiteral()]); | ||
@@ -172,3 +175,2 @@ args = _core().types.callExpression(_core().types.memberExpression(context, _core().types.identifier("concat")), nodes); | ||
} | ||
} | ||
@@ -175,0 +177,0 @@ }; |
{ | ||
"name": "@babel/plugin-transform-spread", | ||
"version": "7.0.0-beta.43", | ||
"version": "7.0.0-beta.44", | ||
"description": "Compile ES2015 spread to ES5", | ||
@@ -12,11 +12,11 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-spread", | ||
"dependencies": { | ||
"@babel/helper-plugin-utils": "7.0.0-beta.43" | ||
"@babel/helper-plugin-utils": "7.0.0-beta.44" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "7.0.0-beta.43" | ||
"@babel/core": "7.0.0-beta.44" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "7.0.0-beta.43", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.43" | ||
"@babel/core": "7.0.0-beta.44", | ||
"@babel/helper-plugin-test-runner": "7.0.0-beta.44" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6428
136
+ Added@babel/code-frame@7.0.0-beta.44(transitive)
+ Added@babel/core@7.0.0-beta.44(transitive)
+ Added@babel/generator@7.0.0-beta.44(transitive)
+ Added@babel/helper-function-name@7.0.0-beta.44(transitive)
+ Added@babel/helper-get-function-arity@7.0.0-beta.44(transitive)
+ Added@babel/helper-plugin-utils@7.0.0-beta.44(transitive)
+ Added@babel/helper-split-export-declaration@7.0.0-beta.44(transitive)
+ Added@babel/helpers@7.0.0-beta.44(transitive)
+ Added@babel/highlight@7.0.0-beta.44(transitive)
+ Added@babel/template@7.0.0-beta.44(transitive)
+ Added@babel/traverse@7.0.0-beta.44(transitive)
+ Added@babel/types@7.0.0-beta.44(transitive)
+ Addedbabylon@7.0.0-beta.44(transitive)
- Removed@babel/code-frame@7.0.0-beta.43(transitive)
- Removed@babel/core@7.0.0-beta.43(transitive)
- Removed@babel/generator@7.0.0-beta.43(transitive)
- Removed@babel/helper-function-name@7.0.0-beta.43(transitive)
- Removed@babel/helper-get-function-arity@7.0.0-beta.43(transitive)
- Removed@babel/helper-plugin-utils@7.0.0-beta.43(transitive)
- Removed@babel/helper-split-export-declaration@7.0.0-beta.43(transitive)
- Removed@babel/helpers@7.0.0-beta.43(transitive)
- Removed@babel/highlight@7.0.0-beta.43(transitive)
- Removed@babel/template@7.0.0-beta.43(transitive)
- Removed@babel/traverse@7.0.0-beta.43(transitive)
- Removed@babel/types@7.0.0-beta.43(transitive)
- Removedbabylon@7.0.0-beta.43(transitive)