Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,3 @@
src
test
node_modules

View File

@@ -0,0 +1,53 @@
# babel-plugin-transform-es2015-typeof-symbol
> ES6 introduces a new native type called [symbols](https://babeljs.io/learn-es2015/#ecmascript-2015-features-symbols). This transformer wraps all `typeof` expressions with a method that replicates native behaviour. (ie. returning "symbol" for symbols)
## Example
**In**
```javascript
typeof Symbol() === "symbol";
```
**Out**
```javascript
var _typeof = function (obj) {
return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
};
_typeof(Symbol()) === "symbol";
```
## Installation
```sh
npm install --save-dev babel-plugin-transform-es2015-typeof-symbol
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["transform-es2015-typeof-symbol"]
}
```
### Via CLI
```sh
babel --plugins transform-es2015-typeof-symbol script.js
```
### Via Node API
```javascript
require("babel-core").transform("code", {
plugins: ["transform-es2015-typeof-symbol"]
});
```

View File

@@ -0,0 +1,59 @@
"use strict";
exports.__esModule = true;
var _symbol = require("babel-runtime/core-js/symbol");
var _symbol2 = _interopRequireDefault(_symbol);
exports.default = function (_ref) {
var t = _ref.types;
var IGNORE = (0, _symbol2.default)();
return {
visitor: {
Scope: function Scope(_ref2) {
var scope = _ref2.scope;
if (!scope.getBinding("Symbol")) {
return;
}
scope.rename("Symbol");
},
UnaryExpression: function UnaryExpression(path) {
var node = path.node,
parent = path.parent;
if (node[IGNORE]) return;
if (path.find(function (path) {
return path.node && !!path.node._generated;
})) return;
if (path.parentPath.isBinaryExpression() && t.EQUALITY_BINARY_OPERATORS.indexOf(parent.operator) >= 0) {
var opposite = path.getOpposite();
if (opposite.isLiteral() && opposite.node.value !== "symbol" && opposite.node.value !== "object") {
return;
}
}
if (node.operator === "typeof") {
var call = t.callExpression(this.addHelper("typeof"), [node.argument]);
if (path.get("argument").isIdentifier()) {
var undefLiteral = t.stringLiteral("undefined");
var unary = t.unaryExpression("typeof", node.argument);
unary[IGNORE] = true;
path.replaceWith(t.conditionalExpression(t.binaryExpression("===", unary, undefLiteral), undefLiteral, call));
} else {
path.replaceWith(call);
}
}
}
}
};
};
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
module.exports = exports["default"];

View File

@@ -0,0 +1,48 @@
{
"_args": [
[
"babel-plugin-transform-es2015-typeof-symbol@6.23.0",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "babel-plugin-transform-es2015-typeof-symbol@6.23.0",
"_id": "babel-plugin-transform-es2015-typeof-symbol@6.23.0",
"_inBundle": false,
"_integrity": "sha1-3sCfHN3/lLUqxz1QXITfWdzOs3I=",
"_location": "/react-scripts/babel-plugin-transform-es2015-typeof-symbol",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "babel-plugin-transform-es2015-typeof-symbol@6.23.0",
"name": "babel-plugin-transform-es2015-typeof-symbol",
"escapedName": "babel-plugin-transform-es2015-typeof-symbol",
"rawSpec": "6.23.0",
"saveSpec": null,
"fetchSpec": "6.23.0"
},
"_requiredBy": [
"/react-scripts/babel-preset-env"
],
"_resolved": "https://registry.npmjs.org/babel-plugin-transform-es2015-typeof-symbol/-/babel-plugin-transform-es2015-typeof-symbol-6.23.0.tgz",
"_spec": "6.23.0",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"dependencies": {
"babel-runtime": "^6.22.0"
},
"description": "This transformer wraps all typeof expressions with a method that replicates native behaviour. (ie. returning “symbol” for symbols)",
"devDependencies": {
"babel-helper-plugin-test-runner": "^6.22.0"
},
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "babel-plugin-transform-es2015-typeof-symbol",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-plugin-transform-es2015-typeof-symbol"
},
"version": "6.23.0"
}