-
-
Notifications
You must be signed in to change notification settings - Fork 919
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
Get the ".last()" value generated of a module #627
Comments
Interesting idea, but why don't you just safe it in a local var in your code? |
I love the idea of a history. But I don't see the responsibility on our side. Since our responsibility is to generate fake data. Not keep track of returned results IMO. |
Well, I use some other generators and I like this approach in one of them, that is to get the last password generated. When using faker I missed something like this but there is no problem to use a var to store it. |
How about a faker.fork().someMethod() // 'FooBar42'
faker.someMethod() // 'FooBar42'
faker.someMethod() // 'FooBar43' Another alternative would be using a seed See also: #448 (comment) |
This actually sounds much more helpful 🤔 |
If the |
We will try to plan something out, but for now I think this is something to target in the far future, so we can focus on the active milestones right now. |
Team Decision We won't implement it as a |
Clear and concise description of the problem
As a developer using faker I want to use some method e.g.
faker.internet.url.last()
to get the latest value generated for this call.If no previous value was generated, this method (or prop) executes like the same
faker.internet.url()
call.So that helps me to avoid create an auxiliary var just to keep this value to use again in another field in the same scope.
Suggested solution
For any faker api module, the "
.last()
" returns the latest value generated, regardless of how the module was called.If undefined, perform the same of no parameter call,
e.g.
faker.address.city.last() // undefined
faker.address.city.last() // same result as faker.address.city()
Alternative
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: