@babel/plugin-transform-instanceof

Example

In

  1. foo instanceof Bar;

Out

  1. function _instanceof(left, right) {
  2. if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
  3. return right[Symbol.hasInstance](left);
  4. } else {
  5. return left instanceof right;
  6. }
  7. }
  8. _instanceof(foo, Bar);

Installation

  1. npm install --save-dev @babel/plugin-transform-instanceof

Usage

.babelrc

  1. {
  2. "plugins": ["@babel/plugin-transform-instanceof"]
  3. }

Via CLI

  1. babel --plugins @babel/plugin-transform-instanceof script.js

Via Node API

  1. require("@babel/core").transform("code", {
  2. plugins: ["@babel/plugin-transform-instanceof"]
  3. });

References