docs:更新文档

This commit is contained in:
张益铭
2021-03-01 15:06:11 +08:00
parent 1542135ab0
commit 9064b372e8
5835 changed files with 904126 additions and 161722 deletions

37
node_modules/is-reference/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,37 @@
# is-reference changelog
## 1.2.1
* Relax version range for `@types/estree`
## 1.2.0
* Handle class fields ([#](https://github.com/Rich-Harris/is-reference/pull/8))
## 1.1.4
* Disregarded imported specifiers if they differ from local specifiers
## 1.1.3
* Handle expressions without a Program
## 1.1.2
* Ignore labels in break/continue statements ([#4](https://github.com/Rich-Harris/is-reference/pull/4))
## 1.1.1
* Prevent false positives with labeled statements
## 1.1.0
* Rewrite in TypeScript, add declarations
## 1.0.1
* Ensure `isReference` returns a boolean
## 1.0.0
* First release

61
node_modules/is-reference/README.md generated vendored Normal file
View File

@@ -0,0 +1,61 @@
# is-reference
Utility for determining whether an AST node is a reference.
`foo` is a reference in these cases:
```js
console.log( foo );
var foo;
function foo () {}
function bar ( foo ) {}
export { foo as x };
```
`foo` is *not* a reference in these cases:
```js
var obj = { foo: 1 };
console.log( obj.foo );
export { x as foo };
```
In all cases, `foo` is an `Identifier` node, but the two kinds must be treated differently for the purposes of scope analysis etc. (The examples are non-exhaustive.)
## Installation
```bash
npm install is-reference
```
## Usage
Example using [Acorn](https://github.com/ternjs/acorn) and [estree-walker](https://github.com/Rich-Harris/estree-walker):
```js
const { parse } = require( 'acorn' );
const { walk } = require( 'estree-walker' );
const isReference = require( 'is-reference' );
const identifiers = [];
const references = [];
const ast = parse( `var a = b.c;` );
walk( ast, {
enter ( node, parent ) {
if ( node.type === 'Identifier' ) identifiers.push( node );
if ( isReference( node, parent ) ) references.push( node );
}
});
identifiers.forEach( node => console.log( node.name ) ); // a, b, c
references.forEach( node => console.log( node.name ) ); // a, b
```
## License
MIT

31
node_modules/is-reference/dist/is-reference.es.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
function isReference(node, parent) {
if (node.type === 'MemberExpression') {
return !node.computed && isReference(node.object, node);
}
if (node.type === 'Identifier') {
if (!parent)
return true;
switch (parent.type) {
// disregard `bar` in `foo.bar`
case 'MemberExpression': return parent.computed || node === parent.object;
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
case 'MethodDefinition': return parent.computed;
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
case 'FieldDefinition': return parent.computed || node === parent.value;
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
case 'Property': return parent.computed || node === parent.value;
// disregard the `bar` in `export { foo as bar }` or
// the foo in `import { foo as bar }`
case 'ExportSpecifier':
case 'ImportSpecifier': return node === parent.local;
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
case 'LabeledStatement':
case 'BreakStatement':
case 'ContinueStatement': return false;
default: return true;
}
}
return false;
}
export default isReference;

39
node_modules/is-reference/dist/is-reference.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.isReference = factory());
}(this, (function () { 'use strict';
function isReference(node, parent) {
if (node.type === 'MemberExpression') {
return !node.computed && isReference(node.object, node);
}
if (node.type === 'Identifier') {
if (!parent)
return true;
switch (parent.type) {
// disregard `bar` in `foo.bar`
case 'MemberExpression': return parent.computed || node === parent.object;
// disregard the `foo` in `class {foo(){}}` but keep it in `class {[foo](){}}`
case 'MethodDefinition': return parent.computed;
// disregard the `foo` in `class {foo=bar}` but keep it in `class {[foo]=bar}` and `class {bar=foo}`
case 'FieldDefinition': return parent.computed || node === parent.value;
// disregard the `bar` in `{ bar: foo }`, but keep it in `{ [bar]: foo }`
case 'Property': return parent.computed || node === parent.value;
// disregard the `bar` in `export { foo as bar }` or
// the foo in `import { foo as bar }`
case 'ExportSpecifier':
case 'ImportSpecifier': return node === parent.local;
// disregard the `foo` in `foo: while (...) { ... break foo; ... continue foo;}`
case 'LabeledStatement':
case 'BreakStatement':
case 'ContinueStatement': return false;
default: return true;
}
}
return false;
}
return isReference;
})));

2
node_modules/is-reference/dist/types/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,2 @@
import { Node } from 'estree';
export default function isReference(node: Node, parent: Node): boolean;

80
node_modules/is-reference/package.json generated vendored Normal file
View File

@@ -0,0 +1,80 @@
{
"_args": [
[
"is-reference@1.2.1",
"J:\\Github\\CURD-TS"
]
],
"_development": true,
"_from": "is-reference@1.2.1",
"_id": "is-reference@1.2.1",
"_inBundle": false,
"_integrity": "sha1-iy2sCzcfS8mU/eq6nrVC0DAC0Lc=",
"_location": "/is-reference",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "is-reference@1.2.1",
"name": "is-reference",
"escapedName": "is-reference",
"rawSpec": "1.2.1",
"saveSpec": null,
"fetchSpec": "1.2.1"
},
"_requiredBy": [
"/@rollup/plugin-commonjs"
],
"_resolved": "http://192.168.250.101:4873/is-reference/-/is-reference-1.2.1.tgz",
"_spec": "1.2.1",
"_where": "J:\\Github\\CURD-TS",
"author": {
"name": "Rich Harris"
},
"bugs": {
"url": "https://github.com/Rich-Harris/is-reference/issues"
},
"dependencies": {
"@types/estree": "*"
},
"description": "Determine whether an AST node is a reference",
"devDependencies": {
"acorn": "^7.2.0",
"acorn-class-fields": "^0.3.2",
"acorn-static-class-features": "^0.2.1",
"estree-walker": "^2.0.1",
"mocha": "^7.1.2",
"rollup": "^2.10.3",
"rollup-plugin-typescript": "^1.0.1",
"tslib": "^2.0.0",
"typescript": "^3.9.2"
},
"files": [
"dist/*.js",
"dist/types/**/*.d.ts"
],
"homepage": "https://github.com/Rich-Harris/is-reference#readme",
"keywords": [
"ast",
"javascript",
"estree",
"acorn"
],
"license": "MIT",
"main": "dist/is-reference.js",
"module": "dist/is-reference.es.js",
"name": "is-reference",
"repository": {
"type": "git",
"url": "git+https://github.com/Rich-Harris/is-reference.git"
},
"scripts": {
"build": "rollup -c && tsc --emitDeclarationOnly",
"prepare": "npm run build",
"prepublishOnly": "npm test",
"pretest": "npm run build",
"test": "mocha"
},
"types": "dist/types/index.d.ts",
"version": "1.2.1"
}