forked from javascript-obfuscator/javascript-obfuscator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStoragesModule.ts
More file actions
43 lines (33 loc) · 2.01 KB
/
Copy pathStoragesModule.ts
File metadata and controls
43 lines (33 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import { ContainerModule, interfaces } from 'inversify';
import { ServiceIdentifiers } from '../../ServiceIdentifiers';
import { TControlFlowStorage } from '../../../types/storages/TControlFlowStorage';
import { TCustomNodeGroupStorage } from '../../../types/storages/TCustomNodeGroupStorage';
import { TStringArrayStorage } from '../../../types/storages/TStringArrayStorage';
import { IRandomGenerator } from '../../../interfaces/utils/IRandomGenerator';
import { ControlFlowStorage } from '../../../storages/control-flow/ControlFlowStorage';
import { CustomNodeGroupStorage } from '../../../storages/custom-node-group/CustomNodeGroupStorage';
import { StringArrayStorage } from '../../../storages/string-array/StringArrayStorage';
export const storagesModule: interfaces.ContainerModule = new ContainerModule((bind: interfaces.Bind) => {
// storages
bind<TCustomNodeGroupStorage>(ServiceIdentifiers.TCustomNodeGroupStorage)
.to(CustomNodeGroupStorage)
.inSingletonScope();
bind<TStringArrayStorage>(ServiceIdentifiers.TStringArrayStorage)
.to(StringArrayStorage)
.inSingletonScope();
bind<interfaces.Newable<TControlFlowStorage>>(ServiceIdentifiers.Newable__TControlFlowStorage)
.toConstructor(ControlFlowStorage);
// controlFlowStorage factory
bind<TControlFlowStorage>(ServiceIdentifiers.Factory__TControlFlowStorage)
.toFactory<TControlFlowStorage>((context: interfaces.Context) => {
return () => {
const constructor: interfaces.Newable<TControlFlowStorage> = context.container
.get<interfaces.Newable<TControlFlowStorage>>(ServiceIdentifiers.Newable__TControlFlowStorage);
const randomGenerator: IRandomGenerator = context.container
.get<IRandomGenerator>(ServiceIdentifiers.IRandomGenerator);
const storage: TControlFlowStorage = new constructor(randomGenerator);
storage.initialize();
return storage;
};
});
});