diff options
Diffstat (limited to 'node_modules/@babel/plugin-proposal-throw-expressions')
3 files changed, 129 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-proposal-throw-expressions/README.md b/node_modules/@babel/plugin-proposal-throw-expressions/README.md new file mode 100644 index 00000000..5ffb4de6 --- /dev/null +++ b/node_modules/@babel/plugin-proposal-throw-expressions/README.md @@ -0,0 +1,47 @@ +# @babel/plugin-proposal-throw-expressions + +This plugin transforms Throw Expressions into an IIFE. + +## Example + +```js +function test(param = throw new Error('required!')) { + const test = param === true || throw new Error('Falsey!'); +} +``` + +## Installation + +```sh +npm install --save-dev @babel/plugin-proposal-throw-expressions +``` + +## Usage + +### Via `.babelrc` (Recommended) + +**.babelrc** + +```json +{ + "plugins": ["@babel/plugin-proposal-throw-expressions"] +} +``` + +### Via CLI + +```sh +babel --plugins @babel/plugin-proposal-throw-expressions script.js +``` + +### Via Node API + +```javascript +require("@babel/core").transform("code", { + plugins: ["@babel/plugin-proposal-throw-expressions"] +}); +``` + +## References + +* [Proposal: ECMAScript throw expressions](https://github.com/tc39/proposal-throw-expressions) diff --git a/node_modules/@babel/plugin-proposal-throw-expressions/lib/index.js b/node_modules/@babel/plugin-proposal-throw-expressions/lib/index.js new file mode 100644 index 00000000..35aaad94 --- /dev/null +++ b/node_modules/@babel/plugin-proposal-throw-expressions/lib/index.js @@ -0,0 +1,60 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; + +function _helperPluginUtils() { + const data = require("@babel/helper-plugin-utils"); + + _helperPluginUtils = function _helperPluginUtils() { + return data; + }; + + return data; +} + +function _pluginSyntaxThrowExpressions() { + const data = _interopRequireDefault(require("@babel/plugin-syntax-throw-expressions")); + + _pluginSyntaxThrowExpressions = function _pluginSyntaxThrowExpressions() { + return data; + }; + + return data; +} + +function _core() { + const data = require("@babel/core"); + + _core = function _core() { + return data; + }; + + return data; +} + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + +var _default = (0, _helperPluginUtils().declare)(api => { + api.assertVersion(7); + return { + inherits: _pluginSyntaxThrowExpressions().default, + visitor: { + UnaryExpression(path) { + const _path$node = path.node, + operator = _path$node.operator, + argument = _path$node.argument; + if (operator !== "throw") return; + + const arrow = _core().types.functionExpression(null, [_core().types.identifier("e")], _core().types.blockStatement([_core().types.throwStatement(_core().types.identifier("e"))])); + + path.replaceWith(_core().types.callExpression(arrow, [argument])); + } + + } + }; +}); + +exports.default = _default;
\ No newline at end of file diff --git a/node_modules/@babel/plugin-proposal-throw-expressions/package.json b/node_modules/@babel/plugin-proposal-throw-expressions/package.json new file mode 100644 index 00000000..34d5954e --- /dev/null +++ b/node_modules/@babel/plugin-proposal-throw-expressions/package.json @@ -0,0 +1,22 @@ +{ + "name": "@babel/plugin-proposal-throw-expressions", + "version": "7.0.0-beta.47", + "description": "Wraps Throw Expressions in an IIFE", + "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-throw-expressions", + "license": "MIT", + "main": "lib/index.js", + "keywords": [ + "babel-plugin" + ], + "dependencies": { + "@babel/helper-plugin-utils": "7.0.0-beta.47", + "@babel/plugin-syntax-throw-expressions": "7.0.0-beta.47" + }, + "peerDependencies": { + "@babel/core": "7.0.0-beta.47" + }, + "devDependencies": { + "@babel/core": "7.0.0-beta.47", + "@babel/helper-plugin-test-runner": "7.0.0-beta.47" + } +} |
