Socket
Socket
Sign inDemoInstall

babel-plugin-transform-es2015-typeof-symbol

Package Overview
Dependencies
1
Maintainers
6
Versions
37
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-transform-es2015-typeof-symbol


Version published
Weekly downloads
1.3M
decreased by-3.3%
Maintainers
6
Created
Weekly downloads
 

Package description

What is babel-plugin-transform-es2015-typeof-symbol?

The babel-plugin-transform-es2015-typeof-symbol npm package is a plugin for Babel that ensures the behavior of the `typeof` operator is spec-compliant when used with symbols, a new primitive type introduced in ES2015 (ES6). It is part of the Babel's ES2015 preset and is used to transform code so that it can run in environments that do not natively support the new symbol type.

What are babel-plugin-transform-es2015-typeof-symbol's main functionalities?

Transform typeof usage with symbols

This code sample demonstrates how the plugin transforms the `typeof` operator when used with a symbol. The plugin adds a helper function to correctly return 'symbol' when the operand is a symbol.

"use strict";

var _typeof = function (obj) {
  return obj && obj.constructor === Symbol ? "symbol" : typeof obj;
};

var sym = Symbol('foo');
console.log(_typeof(sym) === 'symbol'); // true

Other packages similar to babel-plugin-transform-es2015-typeof-symbol

Readme

Source

babel-plugin-transform-es2015-typeof-symbol

Installation

$ npm install babel-plugin-transform-es2015-typeof-symbol

Usage

.babelrc

{
  "plugins": ["transform-es2015-typeof-symbol"]
}

Via CLI

$ babel --plugins transform-es2015-typeof-symbol script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["transform-es2015-typeof-symbol"]
});

Keywords

FAQs

Last updated on 24 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc