Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

regenerator-transform

Package Overview
Dependencies
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regenerator-transform - npm Package Compare versions

Comparing version 0.13.3 to 0.13.4

4

lib/index.js

@@ -6,2 +6,4 @@ "use strict";

var _visit = require("./visit");
/**

@@ -15,3 +17,3 @@ * Copyright (c) 2014-present, Facebook, Inc.

var plugin = {
visitor: require("./visit").getVisitor(context)
visitor: (0, _visit.getVisitor)(context)
}; // Some presets manually call child presets, but fail to pass along the

@@ -18,0 +20,0 @@ // context object. Out of an abundance of caution, we verify that it

@@ -5,5 +5,7 @@ "use strict";

var _emit = require("./emit");
var _util = require("util");
var _util2 = require("./util.js");
var _util2 = require("./util");

@@ -127,6 +129,4 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var Emitter = require("./emit").Emitter;
_assert.default.ok(emitter instanceof _emit.Emitter);
_assert.default.ok(emitter instanceof Emitter);
this.emitter = emitter;

@@ -133,0 +133,0 @@ this.entryStack = [new FunctionEntry(emitter.finalLoc)];

@@ -7,2 +7,4 @@ "use strict";

var _private = require("private");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

@@ -16,4 +18,3 @@

*/
var m = require("private").makeAccessor();
var m = (0, _private.makeAccessor)();
var hasOwn = Object.prototype.hasOwnProperty;

@@ -20,0 +21,0 @@

@@ -19,2 +19,4 @@ /**

var _private = require("private");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }

@@ -96,7 +98,12 @@

var vars = (0, _hoist.hoist)(path);
var didRenameArguments = renameArguments(path, function () {
return t.clone(argsId);
});
var context = {
usesThis: false,
usesArguments: false,
getArgsId: function getArgsId() {
return t.clone(argsId);
}
};
path.traverse(argumentsThisVisitor, context);
if (didRenameArguments) {
if (context.usesArguments) {
vars = vars || t.variableDeclaration("var", []);

@@ -116,8 +123,20 @@ var argumentIdentifier = t.identifier("arguments"); // we need to do this as otherwise arguments in arrow functions gets hoisted

var wrapArgs = [emitter.getContextFunction(innerFnId), // Async functions that are not generators don't care about the
// outer function because they don't need it to be marked and don't
// inherit from its .prototype.
node.generator ? outerFnExpr : t.nullLiteral(), t.thisExpression()];
var wrapArgs = [emitter.getContextFunction(innerFnId)];
var tryLocsList = emitter.getTryLocsList();
if (node.generator) {
wrapArgs.push(outerFnExpr);
} else if (context.usesThis || tryLocsList) {
// Async functions that are not generators don't care about the
// outer function because they don't need it to be marked and don't
// inherit from its .prototype.
wrapArgs.push(t.nullLiteral());
}
if (context.usesThis) {
wrapArgs.push(t.thisExpression());
} else if (tryLocsList) {
wrapArgs.push(t.nullLiteral());
}
if (tryLocsList) {

@@ -196,3 +215,3 @@ wrapArgs.push(tryLocsList);

var getMarkInfo = require("private").makeAccessor();
var getMarkInfo = (0, _private.makeAccessor)();

@@ -237,16 +256,3 @@ function getMarkedFunctionId(funPath) {

function renameArguments(funcPath, getArgsId) {
var state = {
didRenameArguments: false,
getArgsId: getArgsId
};
funcPath.traverse(argumentsVisitor, state); // If the traversal replaced any arguments references, then we need to
// alias the outer function's arguments binding (be it the implicit
// arguments object or some other parameter or variable) to the variable
// named by argsId.
return state.didRenameArguments;
}
var argumentsVisitor = {
var argumentsThisVisitor = {
"FunctionExpression|FunctionDeclaration": function FunctionExpressionFunctionDeclaration(path) {

@@ -258,4 +264,7 @@ path.skip();

util.replaceWithOrRemove(path, state.getArgsId());
state.didRenameArguments = true;
state.usesArguments = true;
}
},
ThisExpression: function ThisExpression(path, state) {
state.usesThis = true;
}

@@ -262,0 +271,0 @@ };

@@ -5,3 +5,3 @@ {

"description": "Explode async and generator functions into a state machine.",
"version": "0.13.3",
"version": "0.13.4",
"main": "lib/index.js",

@@ -36,5 +36,6 @@ "keywords": [

"devDependencies": {
"@babel/cli": "^7.0.0-beta.51",
"@babel/preset-env": "^7.0.0-beta.51"
"@babel/cli": "^7.1.5",
"@babel/core": "^7.1.6",
"@babel/preset-env": "^7.1.6"
}
}

@@ -8,5 +8,7 @@ /**

import { getVisitor } from "./visit";
export default function (context) {
const plugin = {
visitor: require("./visit").getVisitor(context),
visitor: getVisitor(context),
};

@@ -13,0 +15,0 @@

@@ -9,4 +9,5 @@ /**

import assert from "assert";
import { Emitter } from "./emit";
import { inherits } from "util";
import { getTypes } from "./util.js";
import { getTypes } from "./util";

@@ -131,3 +132,2 @@ function Entry() {

let Emitter = require("./emit").Emitter;
assert.ok(emitter instanceof Emitter);

@@ -134,0 +134,0 @@

@@ -10,3 +10,5 @@ /**

import { getTypes } from "./util.js";
let m = require("private").makeAccessor();
import { makeAccessor } from "private";
let m = makeAccessor();
let hasOwn = Object.prototype.hasOwnProperty;

@@ -13,0 +15,0 @@

@@ -15,2 +15,3 @@ /**

import * as util from "./util";
import { makeAccessor } from "private";

@@ -93,4 +94,10 @@ exports.getVisitor = ({ types: t }) => ({

let didRenameArguments = renameArguments(path, () => t.clone(argsId));
if (didRenameArguments) {
let context = {
usesThis: false,
usesArguments: false,
getArgsId: () => t.clone(argsId),
};
path.traverse(argumentsThisVisitor, context);
if (context.usesArguments) {
vars = vars || t.variableDeclaration("var", []);

@@ -112,12 +119,18 @@ const argumentIdentifier = t.identifier("arguments");

let wrapArgs = [
emitter.getContextFunction(innerFnId),
let wrapArgs = [emitter.getContextFunction(innerFnId)];
let tryLocsList = emitter.getTryLocsList();
if (node.generator) {
wrapArgs.push(outerFnExpr);
} else if (context.usesThis || tryLocsList) {
// Async functions that are not generators don't care about the
// outer function because they don't need it to be marked and don't
// inherit from its .prototype.
node.generator ? outerFnExpr : t.nullLiteral(),
t.thisExpression()
];
let tryLocsList = emitter.getTryLocsList();
wrapArgs.push(t.nullLiteral());
}
if (context.usesThis) {
wrapArgs.push(t.thisExpression());
} else if (tryLocsList) {
wrapArgs.push(t.nullLiteral());
}
if (tryLocsList) {

@@ -200,3 +213,3 @@ wrapArgs.push(tryLocsList);

const getMarkInfo = require("private").makeAccessor();
const getMarkInfo = makeAccessor();

@@ -249,18 +262,3 @@ function getMarkedFunctionId(funPath) {

function renameArguments(funcPath, getArgsId) {
let state = {
didRenameArguments: false,
getArgsId: getArgsId
};
funcPath.traverse(argumentsVisitor, state);
// If the traversal replaced any arguments references, then we need to
// alias the outer function's arguments binding (be it the implicit
// arguments object or some other parameter or variable) to the variable
// named by argsId.
return state.didRenameArguments;
}
let argumentsVisitor = {
let argumentsThisVisitor = {
"FunctionExpression|FunctionDeclaration": function(path) {

@@ -273,4 +271,8 @@ path.skip();

util.replaceWithOrRemove(path, state.getArgsId());
state.didRenameArguments = true;
state.usesArguments = true;
}
},
ThisExpression: function(path, state) {
state.usesThis = true;
}

@@ -277,0 +279,0 @@ };

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