1 | import Adjust, { AdjustConstructor } from './adjusts/adjust';
|
2 |
|
3 | interface AdjustMapType {
|
4 | [type: string]: AdjustConstructor;
|
5 | }
|
6 |
|
7 | const ADJUST_MAP: AdjustMapType = {};
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 | const getAdjust = (type: string): AdjustConstructor => {
|
14 | return ADJUST_MAP[type.toLowerCase()];
|
15 | };
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 | const registerAdjust = (type: string, ctor: AdjustConstructor): void => {
|
23 |
|
24 | if (getAdjust(type)) {
|
25 | throw new Error(`Adjust type '${type}' existed.`);
|
26 | }
|
27 |
|
28 | ADJUST_MAP[type.toLowerCase()] = ctor;
|
29 | };
|
30 |
|
31 | export { getAdjust, registerAdjust, Adjust };
|
32 |
|
33 | export * from './interface';
|