Refactor move docs (#8108)

* feat: [skip] generate readme script

* docs: [skip ci] update READMEs

* docs: [skip ci] fix code block type

* chore: [skip ci] move generator script
This commit is contained in:
Sven SAULEAU
2018-06-04 16:32:39 +02:00
committed by Henry Zhu
parent b6eaaa2496
commit b445b79734
143 changed files with 1286 additions and 11238 deletions

View File

@@ -1,62 +1,19 @@
# @babel/plugin-transform-instanceof
> Wraps `instanceof` expressions to allow constructors to customize the logic with a `Symbol.hasInstance` method
> This plugin transforms all the ES2015 'instanceof' methods
## Example
See our website [@babel/plugin-transform-instanceof](https://new.babeljs.io/docs/en/next/babel-plugin-transform-instanceof.html) for more information.
**In**
## Install
```javascript
foo instanceof Bar;
```
**Out**
```javascript
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
Using npm:
```sh
npm install --save-dev @babel/plugin-transform-instanceof
npm install --save @babel/plugin-transform-instanceof
```
## Usage
### Via `.babelrc` (Recommended)
**.babelrc**
```json
{
"plugins": ["@babel/plugin-transform-instanceof"]
}
```
### Via CLI
or using yarn:
```sh
babel --plugins @babel/plugin-transform-instanceof script.js
yarn add --save @babel/plugin-transform-instanceof
```
### Via Node API
```javascript
require("@babel/core").transform("code", {
plugins: ["@babel/plugin-transform-instanceof"]
});
```
## References
* [ES6 Spec: InstanceOf Operator Semantics](https://www.ecma-international.org/ecma-262/6.0/#sec-instanceofoperator)
* [MDN: Symbol.hasInstance](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/hasInstance)