-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
9 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,15 @@ | ||
// parse out just the options we care about | ||
const isParsedConfigSymbol = Symbol('isParsedConfig') | ||
const var1 = Object.freeze({ includePrerelease: true, loose: true, rtl: true, [isParsedConfigSymbol]: true }) | ||
const var2 = Object.freeze({ includePrerelease: true, loose: true, [isParsedConfigSymbol]: true }) | ||
const var3 = Object.freeze({ includePrerelease: true, rtl: true, [isParsedConfigSymbol]: true }) | ||
const var4 = Object.freeze({ includePrerelease: true, [isParsedConfigSymbol]: true }) | ||
const var5 = Object.freeze({ loose: true, rtl: true, [isParsedConfigSymbol]: true }) | ||
const var6 = Object.freeze({ loose: true, [isParsedConfigSymbol]: true }) | ||
const var7 = Object.freeze({ rtl: true, [isParsedConfigSymbol]: true }) | ||
const emptyOpts = Object.freeze({ [isParsedConfigSymbol]: true }) | ||
|
||
const looseOption = Object.freeze({ loose: true }) | ||
const emptyOpts = Object.freeze({ }) | ||
const parseOptions = options => { | ||
if (!options) { | ||
return emptyOpts | ||
} | ||
|
||
if (typeof options !== 'object') { | ||
return var6 | ||
} | ||
|
||
if (options[isParsedConfigSymbol]) { | ||
return options | ||
return looseOption | ||
} | ||
|
||
if (options.includePrerelease) { | ||
if (options.loose && options.rtl) { | ||
return var1 | ||
} | ||
|
||
if (options.loose) { | ||
return var2 | ||
} | ||
|
||
if (options.rtl) { | ||
return var3 | ||
} | ||
|
||
return var4 | ||
} else if (options.loose) { | ||
if (options.rtl) { | ||
return var5 | ||
} | ||
|
||
return var6 | ||
} else if (options.rtl) { | ||
return var7 | ||
} else { | ||
return emptyOpts | ||
} | ||
return options | ||
} | ||
module.exports = parseOptions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters