Total Complexity | 5 |
Complexity/F | 1.67 |
Lines of Code | 22 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | |||
2 | export const PeerDependency = { |
||
3 | X : class PeerDependencyX extends Error { |
||
|
|||
4 | constructor(error) { |
||
5 | super(error.message); |
||
6 | this.name = 'MISSING_PEER_DEPENDENCY'; |
||
7 | this.original = error; |
||
8 | } |
||
9 | }, |
||
10 | |||
11 | load(moduleName) { |
||
12 | try { |
||
13 | // eslint-disable-next-line security/detect-non-literal-require |
||
14 | return require(moduleName); |
||
15 | } catch (error) { |
||
16 | return new this.X(error); |
||
17 | } |
||
18 | }, |
||
19 | |||
20 | check(module) { |
||
21 | if (module instanceof this.X) throw module.original; |
||
22 | } |
||
23 | }; |
||
24 |