aboutsummaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-computed-properties
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/@babel/plugin-transform-computed-properties')
-rw-r--r--node_modules/@babel/plugin-transform-computed-properties/README.md130
-rw-r--r--node_modules/@babel/plugin-transform-computed-properties/lib/index.js225
-rw-r--r--node_modules/@babel/plugin-transform-computed-properties/package.json21
3 files changed, 0 insertions, 376 deletions
diff --git a/node_modules/@babel/plugin-transform-computed-properties/README.md b/node_modules/@babel/plugin-transform-computed-properties/README.md
deleted file mode 100644
index 0a420ba0..00000000
--- a/node_modules/@babel/plugin-transform-computed-properties/README.md
+++ /dev/null
@@ -1,130 +0,0 @@
-# @babel/plugin-transform-computed-properties
-
-> Compile ES2015 computed properties to ES5
-
-## Example
-
-**In**
-
-```js
-var obj = {
- ["x" + foo]: "heh",
- ["y" + bar]: "noo",
- foo: "foo",
- bar: "bar"
-};
-```
-
-**Out**
-
-```js
-var _obj;
-
-function _defineProperty(obj, key, value) {
- if (key in obj) {
- Object.defineProperty(obj, key, {
- value: value,
- enumerable: true,
- configurable: true,
- writable: true
- });
- } else {
- obj[key] = value;
- }
-
- return obj;
-}
-
-var obj = (
- _obj = {},
- _defineProperty(_obj, "x" + foo, "heh"),
- _defineProperty(_obj, "y" + bar, "noo"),
- _defineProperty(_obj, "foo", "foo"),
- _defineProperty(_obj, "bar", "bar"),
- _obj
-);
-```
-
-## Installation
-
-```sh
-npm install --save-dev @babel/plugin-transform-computed-properties
-```
-
-## Usage
-
-### Via `.babelrc` (Recommended)
-
-**.babelrc**
-
-Without options:
-
-```json
-{
- "plugins": ["@babel/plugin-transform-computed-properties"]
-}
-```
-
-With options:
-
-```json
-{
- "plugins": [
- ["@babel/plugin-transform-computed-properties", {
- "loose": true
- }]
- ]
-}
-```
-
-### Via CLI
-
-```sh
-babel --plugins @babel/plugin-transform-computed-properties script.js
-```
-
-### Via Node API
-
-```javascript
-require("@babel/core").transform("code", {
- plugins: ["@babel/plugin-transform-computed-properties"]
-});
-```
-
-## Options
-
-### `loose`
-
-`boolean`, defaults to `false`
-
-Just like method assignment in classes, in loose mode, computed property names
-use simple assignments instead of being defined. This is unlikely to be an issue
-in production code.
-
-#### Example
-
-***In***
-
-```js
-var obj = {
- ["x" + foo]: "heh",
- ["y" + bar]: "noo",
- foo: "foo",
- bar: "bar"
-};
-```
-
-***Out***
-
-```js
-var _obj;
-
-var obj = (
- _obj = {},
- _obj["x" + foo] = "heh",
- _obj["y" + bar] = "noo",
- _obj.foo = "foo",
- _obj.bar = "bar",
- _obj
-);
-```
diff --git a/node_modules/@babel/plugin-transform-computed-properties/lib/index.js b/node_modules/@babel/plugin-transform-computed-properties/lib/index.js
deleted file mode 100644
index 6ae48311..00000000
--- a/node_modules/@babel/plugin-transform-computed-properties/lib/index.js
+++ /dev/null
@@ -1,225 +0,0 @@
-"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 _core() {
- const data = require("@babel/core");
-
- _core = function _core() {
- return data;
- };
-
- return data;
-}
-
-var _default = (0, _helperPluginUtils().declare)((api, options) => {
- api.assertVersion(7);
- const loose = options.loose;
- const pushComputedProps = loose ? pushComputedPropsLoose : pushComputedPropsSpec;
- const buildMutatorMapAssign = (0, _core().template)(`
- MUTATOR_MAP_REF[KEY] = MUTATOR_MAP_REF[KEY] || {};
- MUTATOR_MAP_REF[KEY].KIND = VALUE;
- `);
-
- function getValue(prop) {
- if (_core().types.isObjectProperty(prop)) {
- return prop.value;
- } else if (_core().types.isObjectMethod(prop)) {
- return _core().types.functionExpression(null, prop.params, prop.body, prop.generator, prop.async);
- }
- }
-
- function pushAssign(objId, prop, body) {
- if (prop.kind === "get" && prop.kind === "set") {
- pushMutatorDefine(objId, prop, body);
- } else {
- body.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", _core().types.memberExpression(_core().types.cloneNode(objId), prop.key, prop.computed || _core().types.isLiteral(prop.key)), getValue(prop))));
- }
- }
-
- function pushMutatorDefine({
- body,
- getMutatorId,
- scope
- }, prop) {
- let key = !prop.computed && _core().types.isIdentifier(prop.key) ? _core().types.stringLiteral(prop.key.name) : prop.key;
- const maybeMemoise = scope.maybeGenerateMemoised(key);
-
- if (maybeMemoise) {
- body.push(_core().types.expressionStatement(_core().types.assignmentExpression("=", maybeMemoise, key)));
- key = maybeMemoise;
- }
-
- body.push(...buildMutatorMapAssign({
- MUTATOR_MAP_REF: getMutatorId(),
- KEY: _core().types.cloneNode(key),
- VALUE: getValue(prop),
- KIND: _core().types.identifier(prop.kind)
- }));
- }
-
- function pushComputedPropsLoose(info) {
- for (var _iterator = info.computedProps, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) {
- var _ref;
-
- if (_isArray) {
- if (_i >= _iterator.length) break;
- _ref = _iterator[_i++];
- } else {
- _i = _iterator.next();
- if (_i.done) break;
- _ref = _i.value;
- }
-
- const prop = _ref;
-
- if (prop.kind === "get" || prop.kind === "set") {
- pushMutatorDefine(info, prop);
- } else {
- pushAssign(_core().types.cloneNode(info.objId), prop, info.body);
- }
- }
- }
-
- function pushComputedPropsSpec(info) {
- const objId = info.objId,
- body = info.body,
- computedProps = info.computedProps,
- state = info.state;
-
- for (var _iterator2 = computedProps, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) {
- var _ref2;
-
- if (_isArray2) {
- if (_i2 >= _iterator2.length) break;
- _ref2 = _iterator2[_i2++];
- } else {
- _i2 = _iterator2.next();
- if (_i2.done) break;
- _ref2 = _i2.value;
- }
-
- const prop = _ref2;
-
- const key = _core().types.toComputedKey(prop);
-
- if (prop.kind === "get" || prop.kind === "set") {
- pushMutatorDefine(info, prop);
- } else if (_core().types.isStringLiteral(key, {
- value: "__proto__"
- })) {
- pushAssign(objId, prop, body);
- } else {
- if (computedProps.length === 1) {
- return _core().types.callExpression(state.addHelper("defineProperty"), [info.initPropExpression, key, getValue(prop)]);
- } else {
- body.push(_core().types.expressionStatement(_core().types.callExpression(state.addHelper("defineProperty"), [_core().types.cloneNode(objId), key, getValue(prop)])));
- }
- }
- }
- }
-
- return {
- visitor: {
- ObjectExpression: {
- exit(path, state) {
- const node = path.node,
- parent = path.parent,
- scope = path.scope;
- let hasComputed = false;
- var _arr = node.properties;
-
- for (var _i3 = 0; _i3 < _arr.length; _i3++) {
- const prop = _arr[_i3];
- hasComputed = prop.computed === true;
- if (hasComputed) break;
- }
-
- if (!hasComputed) return;
- const initProps = [];
- const computedProps = [];
- let foundComputed = false;
-
- for (var _iterator3 = node.properties, _isArray3 = Array.isArray(_iterator3), _i4 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) {
- var _ref3;
-
- if (_isArray3) {
- if (_i4 >= _iterator3.length) break;
- _ref3 = _iterator3[_i4++];
- } else {
- _i4 = _iterator3.next();
- if (_i4.done) break;
- _ref3 = _i4.value;
- }
-
- const prop = _ref3;
-
- if (prop.computed) {
- foundComputed = true;
- }
-
- if (foundComputed) {
- computedProps.push(prop);
- } else {
- initProps.push(prop);
- }
- }
-
- const objId = scope.generateUidIdentifierBasedOnNode(parent);
-
- const initPropExpression = _core().types.objectExpression(initProps);
-
- const body = [];
- body.push(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(objId, initPropExpression)]));
- let mutatorRef;
-
- const getMutatorId = function getMutatorId() {
- if (!mutatorRef) {
- mutatorRef = scope.generateUidIdentifier("mutatorMap");
- body.push(_core().types.variableDeclaration("var", [_core().types.variableDeclarator(mutatorRef, _core().types.objectExpression([]))]));
- }
-
- return _core().types.cloneNode(mutatorRef);
- };
-
- const single = pushComputedProps({
- scope,
- objId,
- body,
- computedProps,
- initPropExpression,
- getMutatorId,
- state
- });
-
- if (mutatorRef) {
- body.push(_core().types.expressionStatement(_core().types.callExpression(state.addHelper("defineEnumerableProperties"), [_core().types.cloneNode(objId), _core().types.cloneNode(mutatorRef)])));
- }
-
- if (single) {
- path.replaceWith(single);
- } else {
- body.push(_core().types.expressionStatement(_core().types.cloneNode(objId)));
- path.replaceWithMultiple(body);
- }
- }
-
- }
- }
- };
-});
-
-exports.default = _default; \ No newline at end of file
diff --git a/node_modules/@babel/plugin-transform-computed-properties/package.json b/node_modules/@babel/plugin-transform-computed-properties/package.json
deleted file mode 100644
index b33b08d8..00000000
--- a/node_modules/@babel/plugin-transform-computed-properties/package.json
+++ /dev/null
@@ -1,21 +0,0 @@
-{
- "name": "@babel/plugin-transform-computed-properties",
- "version": "7.0.0-beta.47",
- "description": "Compile ES2015 computed properties to ES5",
- "repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-computed-properties",
- "license": "MIT",
- "main": "lib/index.js",
- "keywords": [
- "babel-plugin"
- ],
- "dependencies": {
- "@babel/helper-plugin-utils": "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"
- }
-}