-
-
Notifications
You must be signed in to change notification settings - Fork 880
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(helpers): fake from array #1453
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## next #1453 +/- ##
========================================
Coverage 99.64% 99.65%
========================================
Files 2244 2244
Lines 240413 240509 +96
Branches 1071 1076 +5
========================================
+ Hits 239562 239674 +112
+ Misses 830 814 -16
Partials 21 21
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, I don't like this change, as it adds a lot of "unnecessary" complexity on top of an already complex function.
But I don't see anything wrong with the implementation itself.
@xDivisionByZerox Would you prefer a separate method? Any suggestions for a name? |
A separate method would definitely satisfy the single responsibility principle. But I guess that would negate the overall code improvement you had in mind with this changes? As now every function is required to first check the type and then call the according function: function foo(options: string | string[]) {
return Array.isArray(options)
? this.faker.helpers.fakeOneOf(options)
: this faker.helpers.fake(options);
} |
Co-authored-by: Shinigami <chrissi92@hotmail.de>
Fixes #1446
Example Usage:
Docs Preview