Remove unnecessary Store subclass.

This commit is contained in:
Logan Smyth 2017-09-29 11:05:57 -07:00
parent 1938f490b3
commit c8835cbbee
3 changed files with 20 additions and 22 deletions

View File

@ -9,7 +9,6 @@ import sourceMap from "source-map";
import generate from "babel-generator";
import { codeFrameColumns } from "babel-code-frame";
import traverse from "babel-traverse";
import Store from "../store";
import { parse } from "babylon";
import * as t from "babel-types";
import buildDebug from "debug";
@ -38,7 +37,7 @@ const errorVisitor = {
},
};
export default class File extends Store {
export default class File {
constructor({ options, passes }: ResolvedConfig) {
if (!INTERNAL_PLUGINS) {
// Lazy-init the internal plugin to remove the init-time circular dependency between plugins being
@ -49,8 +48,7 @@ export default class File extends Store {
}).passes[0];
}
super();
this._map = new Map();
this.pluginPasses = passes;
this.opts = options;
@ -113,6 +111,14 @@ export default class File extends Store {
code: string;
shebang: string;
set(key: string, val) {
this._map.set(key, val);
}
get(key: string): any {
return this._map.get(key);
}
getMetadata() {
let has = false;
for (const node of (this.ast.program.body: Array<Object>)) {

View File

@ -1,9 +1,8 @@
import Store from "./store";
import File from "./file";
export default class PluginPass extends Store {
export default class PluginPass {
constructor(file: File, key: string, options: Object = {}) {
super();
this._map = new Map();
this.key = key;
this.file = file;
@ -14,6 +13,14 @@ export default class PluginPass extends Store {
file: File;
opts: Object;
set(key: string, val) {
this._map.set(key, val);
}
get(key: string): any {
return this._map.get(key);
}
addHelper(...args) {
return this.file.addHelper(...args);
}

View File

@ -1,15 +0,0 @@
export default class Store {
constructor() {
this._map = new Map();
}
set(key: string, val) {
this._map.set(key, val);
}
get(key: string): any {
if (this._map.has(key)) {
return this._map.get(key);
}
}
}