|
| 1 | +const var1 = Object.freeze({ includePrerelease: true, loose: true, rtl: true }); |
| 2 | +const var2 = Object.freeze({ includePrerelease: true, loose: true }); |
| 3 | +const var3 = Object.freeze({ includePrerelease: true, rtl: true }); |
| 4 | +const var4 = Object.freeze({ includePrerelease: true }); |
| 5 | +const var5 = Object.freeze({ loose: true, rtl: true }); |
| 6 | +const var6 = Object.freeze({ loose: true }); |
| 7 | +const var7 = Object.freeze({ rtl: true }); |
| 8 | +const emptyOpts = Object.freeze({}); |
| 9 | + |
1 | 10 | const parseOptions = options => {
|
2 |
| - if (!options) return {}; |
| 11 | + if (!options) return emptyOpts; |
| 12 | + |
| 13 | + if (typeof options !== 'object') return var6; |
3 | 14 |
|
4 |
| - if (typeof options !== 'object') return { loose: true }; |
| 15 | + if (options.includePrerelease) { |
| 16 | + if (options.loose && options.rtl) { |
| 17 | + return var1; |
| 18 | + } |
5 | 19 |
|
6 |
| - const parsedOptions = {}; |
| 20 | + if (options.loose) { |
| 21 | + return var2; |
| 22 | + } |
7 | 23 |
|
8 |
| - // parse out just the options we care about so we always get a consistent |
9 |
| - // obj with keys in a consistent order. |
| 24 | + if (options.rtl) { |
| 25 | + return var3; |
| 26 | + } |
10 | 27 |
|
11 |
| - if (options.includePrerelease) parsedOptions.includePrerelease = true; |
12 |
| - if (options.loose) parsedOptions.loose = true; |
13 |
| - if (options.rtl) parsedOptions.rtl = true; |
| 28 | + return var4; |
| 29 | + } else if (options.loose) { |
| 30 | + if (options.rtl) { |
| 31 | + return var5; |
| 32 | + } |
14 | 33 |
|
15 |
| - return parsedOptions; |
| 34 | + return var6; |
| 35 | + } else if (options.rtl) { |
| 36 | + return var7; |
| 37 | + } else { |
| 38 | + return emptyOpts; |
| 39 | + } |
16 | 40 | };
|
17 | 41 | module.exports = parseOptions;
|
0 commit comments