New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regenerator

Package Overview
Dependencies
Maintainers
1
Versions
149
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regenerator - npm Package Compare versions

Comparing version 0.6.0 to 0.6.1

36

lib/visit.js

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

var runtimeValuesMethod = runtimeProperty("values");
var runtimeAsyncMethod = runtimeProperty("async");

@@ -37,3 +38,3 @@ exports.transform = function(node) {

if (!node.generator) {
if (!node.generator && !node.async) {
return;

@@ -52,5 +53,10 @@ }

if (node.async) {
awaitVisitor.visit(path.get("body"));
}
var outerFnId = node.id || (
node.id = path.scope.parent.declareTemporary("callee$")
);
var innerFnId = b.identifier(node.id.name + "$");

@@ -80,3 +86,5 @@ var contextId = path.scope.declareTemporary("context$");

emitter.getContextFunction(innerFnId),
outerFnId,
// Async functions don't care about the outer function because they
// don't need it to be marked and don't inherit from its .prototype.
node.async ? b.literal(null) : outerFnId,
b.thisExpression()

@@ -90,8 +98,15 @@ ];

outerBody.push(b.returnStatement(
b.callExpression(runtimeWrapMethod, wrapArgs)
));
var wrapCall = b.callExpression(
node.async ? runtimeAsyncMethod : runtimeWrapMethod,
wrapArgs
);
outerBody.push(b.returnStatement(wrapCall));
node.body = b.blockStatement(outerBody);
if (node.async) {
node.async = false;
return;
}
if (n.FunctionDeclaration.check(node)) {

@@ -333,1 +348,12 @@ var pp = path.parent;

}
var awaitVisitor = types.PathVisitor.fromMethodsObject({
visitFunction: function(path) {
return false; // Don't descend into nested function scopes.
},
visitAwaitExpression: function(path) {
// Convert await expressions to yield expressions.
return b.yieldExpression(path.value.argument, false);
}
});

8

main.js

@@ -19,3 +19,3 @@ /**

var types = recast.types;
var genFunExp = /\bfunction\s*\*/;
var genOrAsyncFunExp = /\bfunction\s*\*|\basync\b/;
var blockBindingExp = /\b(let|const)\s+/;

@@ -49,4 +49,4 @@ var runtimePath = path.join(__dirname, "runtime.js");

if (!genFunExp.test(source)) {
// Shortcut: no generators to transform.
if (!genOrAsyncFunExp.test(source)) {
// Shortcut: no generators or async functions to transform.
return { code: runtime + source };

@@ -177,3 +177,3 @@ }

exports.runtime = function runtime() {
require("regenerator/runtime");
require("./runtime");
};

@@ -19,3 +19,3 @@ {

],
"version": "0.6.0",
"version": "0.6.1",
"homepage": "http://github.com/facebook/regenerator",

@@ -33,4 +33,5 @@ "repository": {

"commander": "~2.1.0",
"esprima-fb": "5001.1.0-dev-harmony-fb",
"esprima-fb": "~6001.1001.0-dev-harmony-fb",
"recast": "~0.7.1",
"promise": "~5.0.0",
"private": "~0.1.5",

@@ -37,0 +38,0 @@ "through": "~2.3.4",

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

var undefined; // More compressible than void 0.
var Promise = global.Promise || (global.Promise = require("promise"));

@@ -56,2 +57,27 @@ if (global.regeneratorRuntime) {

runtime.async = function(innerFn, self, tryList) {
return new Promise(function(resolve, reject) {
var generator = wrap(innerFn, self, tryList);
var callNext = step.bind(generator.next);
var callThrow = step.bind(generator.throw);
function step(arg) {
try {
var info = this(arg);
var value = info.value;
} catch (error) {
return reject(error);
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(callNext, callThrow);
}
}
callNext();
});
};
// Ensure isGeneratorFunction works when Function#name not supported.

@@ -58,0 +84,0 @@ if (GeneratorFunction.name !== "GeneratorFunction") {

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