mirror of
https://github.com/pure-admin/vue-pure-admin.git
synced 2025-11-21 14:13:36 +08:00
docs:更新文档
This commit is contained in:
39
node_modules/estree-walker/src/walker.ts
generated
vendored
Normal file
39
node_modules/estree-walker/src/walker.ts
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
import { BaseNode } from "estree";
|
||||
|
||||
export type WalkerContext = {
|
||||
skip: () => void;
|
||||
remove: () => void;
|
||||
replace: (node: BaseNode) => void;
|
||||
};
|
||||
|
||||
export class WalkerBase {
|
||||
protected should_skip: boolean = false;
|
||||
protected should_remove: boolean = false;
|
||||
protected replacement: BaseNode = null;
|
||||
|
||||
public context: WalkerContext = {
|
||||
skip: () => (this.should_skip = true),
|
||||
remove: () => (this.should_remove = true),
|
||||
replace: (node: BaseNode) => (this.replacement = node)
|
||||
};
|
||||
|
||||
public replace(parent: any, prop: string, index: number, node: BaseNode) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop][index] = node;
|
||||
} else {
|
||||
parent[prop] = node;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public remove(parent: any, prop: string, index: number) {
|
||||
if (parent) {
|
||||
if (index !== null) {
|
||||
parent[prop].splice(index, 1);
|
||||
} else {
|
||||
delete parent[prop];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user