Socket
Socket
Sign inDemoInstall

es6-spread

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-spread - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

test/examples/iterator.js

2

bower.json
{
"name": "es6-spread",
"version": "0.0.5",
"version": "0.0.6",
"homepage": "https://github.com/square/es6-spread",

@@ -5,0 +5,0 @@ "authors": [

@@ -115,5 +115,5 @@ /* jshint node:true, undef:true, unused:true */

arrays.push(
util.callArraySlice(
accumulateIteratorValues(
scope.getGlobalScope(),
element.argument
util.callGetIterator(scope.getGlobalScope(), element.argument)
)

@@ -149,2 +149,88 @@ );

/**
* var accumulateIteratorValues = function(iterator) {
* var result = [];
* for (var $__0 = iterator, $__1; !($__1 = $__0.next()).done; ) {
* result.push($__1.value);
* }
* return result;
* };
*
* @private
* @param {ast-types.Scope}
* @param {ast-types.Expression}
*/
function accumulateIteratorValues(scope, iterator) {
var accumulate = util.injectShared(
scope,
'accumulateIteratorValues',
function() {
var iteratorId = b.identifier('iterator');
var nextId = b.identifier('next');
var resultId = b.identifier('result');
var itemId = b.identifier('item');
var doneId = b.identifier('done');
var valueId = b.identifier('value');
return b.functionExpression(
null,
[iteratorId],
b.blockStatement([
b.variableDeclaration(
'var',
[b.variableDeclarator(
resultId,
b.arrayExpression([])
)]
),
b.forStatement(
b.variableDeclaration(
'var',
[b.variableDeclarator(itemId, null)]
),
b.unaryExpression(
'!',
b.memberExpression(
b.assignmentExpression(
'=',
itemId,
b.callExpression(
b.memberExpression(
iteratorId,
nextId,
false
),
[]
)
),
doneId,
false
)
),
null,
b.expressionStatement(b.callExpression(
b.memberExpression(
resultId,
b.identifier('push'),
false
),
[b.memberExpression(
itemId,
valueId,
false
)]
))
),
b.returnStatement(resultId)
])
);
}
);
return b.callExpression(
accumulate,
[iterator]
);
}
/**
* Transform an Esprima AST generated from ES6 by replacing all spread elements

@@ -151,0 +237,0 @@ * with an equivalent approach in ES5.

{
"name": "es6-spread",
"version": "0.0.5",
"version": "0.0.6",
"description": "ES6 spread compiled to ES5.",

@@ -18,3 +18,3 @@ "main": "lib/index.js",

"through": "~2.3.4",
"ast-util": "^0.0.5"
"ast-util": "^0.1.0"
},

@@ -21,0 +21,0 @@ "devDependencies": {

# es6-spread
Compiles JavaScript written using ES6 spread syntax to use the equivalent ES5
code. For example, this:
code. For example, this spreads `args` out as positional arguments to `f`:

@@ -12,10 +12,2 @@ ```js

compiles to this:
```js
function f(x, y, z) { }
var args = [0, 1, 2];
f.apply(null, args);
```
This project is part of [esnext][esnext], a project to compile the syntax of

@@ -22,0 +14,0 @@ the next version of JavaScript to today's JavaScript environments.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc