@babel/plugin-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
With a configuration file (Recommended)
{
"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"]
});