Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
66 lines (46 sloc) 1.12 KB
---
id: babel-plugin-transform-instanceof
title: @babel/plugin-transform-instanceof
sidebar_label: transform-instanceof
---

Example

In

foo instanceof Bar;

Out

function _instanceof(left, right) {
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
    return right[Symbol.hasInstance](left);
  } else {
    return left instanceof right;
  }
}

_instanceof(foo, Bar);

Installation

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

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["@babel/plugin-transform-instanceof"]
}

Via CLI

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

Via Node API

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

References

You can’t perform that action at this time.