6350892700c2215fc556209972442e512c5ffa0244f21657695afc9aac9c787519ad04968c304d273ddd60c2a704f6d70bfda14abbd2ed9efe64052a0a28f4 960 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # babel-plugin-transform-es2015-typeof-symbol
  2. > 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)
  3. ## Example
  4. **In**
  5. ```javascript
  6. typeof Symbol() === "symbol";
  7. ```
  8. **Out**
  9. ```javascript
  10. var _typeof = function (obj) {
  11. return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
  12. };
  13. _typeof(Symbol()) === "symbol";
  14. ```
  15. ## Installation
  16. ```sh
  17. npm install --save-dev babel-plugin-transform-es2015-typeof-symbol
  18. ```
  19. ## Usage
  20. ### Via `.babelrc` (Recommended)
  21. **.babelrc**
  22. ```json
  23. {
  24. "plugins": ["transform-es2015-typeof-symbol"]
  25. }
  26. ```
  27. ### Via CLI
  28. ```sh
  29. babel --plugins transform-es2015-typeof-symbol script.js
  30. ```
  31. ### Via Node API
  32. ```javascript
  33. require("babel-core").transform("code", {
  34. plugins: ["transform-es2015-typeof-symbol"]
  35. });
  36. ```