summaryrefslogtreecommitdiff
path: root/node_modules/babel-plugin-transform-undefined-to-void
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
committerlittleblack111 <littleblack11111@gmail.com>2024-08-30 17:21:18 +0800
commitefbc2ffe6a1ee5ec38a4396305561d6515d0943e (patch)
tree2b4c94f18f2c792dfda813050755d5c0273fae22 /node_modules/babel-plugin-transform-undefined-to-void
parent43acceb75957c880a5ba5a31aae221394a36d5f6 (diff)
node fixes, updates
Diffstat (limited to 'node_modules/babel-plugin-transform-undefined-to-void')
-rw-r--r--node_modules/babel-plugin-transform-undefined-to-void/README.md51
-rw-r--r--node_modules/babel-plugin-transform-undefined-to-void/lib/index.js18
-rw-r--r--node_modules/babel-plugin-transform-undefined-to-void/package.json14
3 files changed, 83 insertions, 0 deletions
diff --git a/node_modules/babel-plugin-transform-undefined-to-void/README.md b/node_modules/babel-plugin-transform-undefined-to-void/README.md
new file mode 100644
index 00000000..58989c65
--- /dev/null
+++ b/node_modules/babel-plugin-transform-undefined-to-void/README.md
@@ -0,0 +1,51 @@
+# babel-plugin-transform-undefined-to-void
+
+Some JavaScript implementations allow undefined to be overwritten, this may lead to peculiar bugs that are extremely hard to track down.
+
+This plugin transforms `undefined` into `void 0` which returns undefined regardless of if it's been reassigned.
+
+## Example
+
+**In**
+
+```javascript
+foo === undefined;
+```
+
+**Out**
+
+```javascript
+foo === void 0;
+```
+
+## Installation
+
+```sh
+npm install babel-plugin-transform-undefined-to-void --save-dev
+```
+
+## Usage
+
+### Via `.babelrc` (Recommended)
+
+**.babelrc**
+
+```json
+{
+ "plugins": ["transform-undefined-to-void"]
+}
+```
+
+### Via CLI
+
+```sh
+babel --plugins transform-undefined-to-void script.js
+```
+
+### Via Node API
+
+```javascript
+require("@babel/core").transform("code", {
+ plugins: ["transform-undefined-to-void"]
+});
+```
diff --git a/node_modules/babel-plugin-transform-undefined-to-void/lib/index.js b/node_modules/babel-plugin-transform-undefined-to-void/lib/index.js
new file mode 100644
index 00000000..6e9c1e09
--- /dev/null
+++ b/node_modules/babel-plugin-transform-undefined-to-void/lib/index.js
@@ -0,0 +1,18 @@
+"use strict";
+
+module.exports = function ({
+ types: t
+}) {
+ const VOID_0 = t.unaryExpression("void", t.numericLiteral(0), true);
+ return {
+ name: "transform-undefined-to-void",
+ visitor: {
+ ReferencedIdentifier(path) {
+ if (path.node.name === "undefined") {
+ path.replaceWith(VOID_0);
+ }
+ }
+
+ }
+ };
+}; \ No newline at end of file
diff --git a/node_modules/babel-plugin-transform-undefined-to-void/package.json b/node_modules/babel-plugin-transform-undefined-to-void/package.json
new file mode 100644
index 00000000..fdf80dbf
--- /dev/null
+++ b/node_modules/babel-plugin-transform-undefined-to-void/package.json
@@ -0,0 +1,14 @@
+{
+ "name": "babel-plugin-transform-undefined-to-void",
+ "version": "6.9.4",
+ "description": "Replace references to `undefined` with `void 0`",
+ "keywords": [
+ "babel-plugin"
+ ],
+ "homepage": "https://github.com/babel/minify#readme",
+ "bugs": "https://github.com/babel/minify/issues",
+ "license": "MIT",
+ "author": "amasad",
+ "main": "lib/index.js",
+ "repository": "https://github.com/babel/minify/tree/master/packages/babel-plugin-transform-undefined-to-void"
+}