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

babel-helper-remap-async-to-generator

Package Overview
Dependencies
Maintainers
6
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-helper-remap-async-to-generator - npm Package Compare versions

Comparing version 7.0.0-beta.2 to 7.0.0-beta.3

35

lib/for-await.js
"use strict";
exports.__esModule = true;
exports.default = _default;
exports.default = function (path, helpers) {
var t = _interopRequireWildcard(require("babel-types"));
var _babelTemplate = _interopRequireDefault(require("babel-template"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var awaitTemplate = "\n function* wrapper() {\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (\n var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE;\n (\n STEP_KEY = yield AWAIT(ITERATOR_KEY.next()),\n ITERATOR_COMPLETION = STEP_KEY.done,\n STEP_VALUE = yield AWAIT(STEP_KEY.value),\n !ITERATOR_COMPLETION\n );\n ITERATOR_COMPLETION = true) {\n }\n } catch (err) {\n ITERATOR_HAD_ERROR_KEY = true;\n ITERATOR_ERROR_KEY = err;\n } finally {\n try {\n if (!ITERATOR_COMPLETION && ITERATOR_KEY.return != null) {\n yield AWAIT(ITERATOR_KEY.return());\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n }\n";
var buildForAwait = (0, _babelTemplate.default)(awaitTemplate);
var buildForAwaitWithoutWrapping = (0, _babelTemplate.default)(awaitTemplate.replace(/\bAWAIT\b/g, ""));
function _default(path, helpers) {
var node = path.node,

@@ -12,3 +25,3 @@ scope = path.scope,

var left = node.left;
var declar = void 0;
var declar;

@@ -48,18 +61,2 @@ if (t.isIdentifier(left) || t.isPattern(left) || t.isMemberExpression(left)) {

};
};
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _babelTemplate = require("babel-template");
var _babelTemplate2 = _interopRequireDefault(_babelTemplate);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
var awaitTemplate = "\n function* wrapper() {\n var ITERATOR_COMPLETION = true;\n var ITERATOR_HAD_ERROR_KEY = false;\n var ITERATOR_ERROR_KEY = undefined;\n try {\n for (\n var ITERATOR_KEY = GET_ITERATOR(OBJECT), STEP_KEY, STEP_VALUE;\n (\n STEP_KEY = yield AWAIT(ITERATOR_KEY.next()),\n ITERATOR_COMPLETION = STEP_KEY.done,\n STEP_VALUE = yield AWAIT(STEP_KEY.value),\n !ITERATOR_COMPLETION\n );\n ITERATOR_COMPLETION = true) {\n }\n } catch (err) {\n ITERATOR_HAD_ERROR_KEY = true;\n ITERATOR_ERROR_KEY = err;\n } finally {\n try {\n if (!ITERATOR_COMPLETION && ITERATOR_KEY.return != null) {\n yield AWAIT(ITERATOR_KEY.return());\n }\n } finally {\n if (ITERATOR_HAD_ERROR_KEY) {\n throw ITERATOR_ERROR_KEY;\n }\n }\n }\n }\n";
var buildForAwait = (0, _babelTemplate2.default)(awaitTemplate);
var buildForAwaitWithoutWrapping = (0, _babelTemplate2.default)(awaitTemplate.replace(/\bAWAIT\b/g, ""));
}
"use strict";
exports.__esModule = true;
exports.default = _default;
exports.default = function (path, file, helpers) {
if (!helpers) {
helpers = {
wrapAsync: file
};
file = null;
}
var _babelHelperWrapFunction = _interopRequireDefault(require("babel-helper-wrap-function"));
path.traverse(awaitVisitor, {
file: file,
wrapAwait: helpers.wrapAwait
});
path.node.async = false;
path.node.generator = true;
(0, _babelHelperWrapFunction2.default)(path, helpers.wrapAsync);
};
var t = _interopRequireWildcard(require("babel-types"));
var _babelHelperWrapFunction = require("babel-helper-wrap-function");
var _forAwait = _interopRequireDefault(require("./for-await"));
var _babelHelperWrapFunction2 = _interopRequireDefault(_babelHelperWrapFunction);
var _babelTypes = require("babel-types");
var t = _interopRequireWildcard(_babelTypes);
var _forAwait = require("./for-await");
var _forAwait2 = _interopRequireDefault(_forAwait);
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)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }

@@ -56,3 +34,3 @@

if (!node.await) return;
var build = (0, _forAwait2.default)(path, {
var build = (0, _forAwait.default)(path, {
getAsyncIterator: file.addHelper("asyncIterator"),

@@ -80,2 +58,12 @@ wrapAwait: wrapAwait

}
};
};
function _default(path, file, helpers) {
path.traverse(awaitVisitor, {
file: file,
wrapAwait: helpers.wrapAwait
});
path.node.async = false;
path.node.generator = true;
(0, _babelHelperWrapFunction.default)(path, helpers.wrapAsync);
}
{
"name": "babel-helper-remap-async-to-generator",
"version": "7.0.0-beta.2",
"version": "7.0.0-beta.3",
"description": "Helper function to remap async functions to generators",

@@ -9,7 +9,7 @@ "repository": "https://github.com/babel/babel/tree/master/packages/babel-helper-remap-async-to-generator",

"dependencies": {
"babel-helper-wrap-function": "7.0.0-beta.2",
"babel-template": "7.0.0-beta.2",
"babel-traverse": "7.0.0-beta.2",
"babel-types": "7.0.0-beta.2"
"babel-helper-wrap-function": "7.0.0-beta.3",
"babel-template": "7.0.0-beta.3",
"babel-traverse": "7.0.0-beta.3",
"babel-types": "7.0.0-beta.3"
}
}
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