Closed kharann closed 6 months ago
Perhaps we should have a new function in the animal
module that pulls from all animal definitions?
I'm pretty sure we shouldn't use random
as a method name because all methods return random data.
Instead of returning a complex breed or race of animal, the new method should return the type or category (e.g. dog, cat, ...). Not sure what the actual name for that is. Maybe just type()
?
We could still stick to what we discussed for other stuff and just use sample
To shorten it for the long run, we could also use sample({ category/species?: '' })
Beside that type
is not what the issue creator asked for, I'm against type
as it conflicts with TypeScript's keyword type
That is why many code bases written in TS uses kind
instead
We could still stick to what we discussed for other stuff and just use
sample
I also thought about that but I would expect sample to return something like a mixture of the others e.g. Messouri Fox Trotter (Horse) or Red House Cat.
Beside that
type
is not what the issue creator asked for, I'm againsttype
as it conflicts with TypeScript's keywordtype
That is why many code bases written in TS useskind
instead
I think type
/category
/kind
(e.g. cat, lion, eagle) is exactly what @kharann asked for (Please correct me if I'm wrong). I fine with naming it kind
over type
. But I would have to spend some time to browse some animal categorization literature and their simplified variants.
We could still stick to what we discussed for other stuff and just use
sample
I also thought about that but I would expect sample to return something like a mixture of the others e.g. Messouri Fox Trotter (Horse) or Red House Cat.
Beside that
type
is not what the issue creator asked for, I'm againsttype
as it conflicts with TypeScript's keywordtype
That is why many code bases written in TS useskind
insteadI think
type
/category
/kind
(e.g. cat, lion, eagle) is exactly what @kharann asked for (Please correct me if I'm wrong). I fine with naming itkind
overtype
. But I would have to spend some time to browse some animal categorization literature and their simplified variants.
I did ask for any kind of animal. Right now you have to choose a category, as there's no method that returns any kind of animal
Oh thanks for the clarification, so I really misunderstood you first, I'm sorry 🙇
So yeah, we could go with kind
or category
A brain-cell in my head yells that species
is not correct here 🤔
Honestly, at first i was thinking something like faker.animal.any()
, but I think any is also kinda cursed as a word in TypeScript world
Honestly, at first i was thinking something like
faker.animal.any()
, but I think any is also kinda cursed as a word in TypeScript world
We had this discussion already with the word module.
Yes we want to omit terms like type
, any
and random
Team decision
If you want/need this feature, please upvote this issue.
You can use the following as a workaround in the meantime.
faker.helpers.objectValue(faker.animal)();
Team decision
If you want/need this feature, please upvote this issue.
You can use the following as a workaround in the meantime.
faker.helpers.objectValue(faker.animal)();
This is for now an okay-ish workaround, but keep in mind that it is not future proof to do this, as well as it theoretically comes with a "bug" on the expectation point of view.
type
method would get called which does not return an animal but the type of an animal
But theoretically this is not that important if it only is used for a test, as then it is "just" a string. But keep in mind if you doing it for Demo purposes.
type
method (the current addressing PR also has this bug and would need to be adjusted)typeOfAnimals
Would it be good to have a method which just returns a "simple" animal? Like i might just want a common one word animal name like:
dog
cat
monkey
elephant
deer
camel
whale
sheep
goat
rather than African Slender-snouted Crocodile
Would it be good to have a method which just returns a "simple" animal? Like i might just want a common one word animal name like:
dog cat monkey elephant deer camel whale sheep goat
rather than
African Slender-snouted Crocodile
Is that localizable though?
Is that localizable though?
Sure.
hmm but it looks like its supposed to return one of the other method names, ie you can do:
faker.animal[faker.animal.type()]()
to get a animal of any type? Or is that a coincidence and not expected to be maintained? i think "crocodilia", "cetacean" etc are not what i'd expect if i wanted an animal?
Seems like in v5.5.3 they were already localized (seems wired to me and like a design issue)
But at least the en locale entries reflect exact what were used as method names (as my expectations)
So at the end, I have the same expectations as @matthewmayer for the type
function
Maybe we could even convert this into an Enum like Sex/SexType and the others
I'm not sure whether cetacean
or crocodilia
is the correct return value either, I think crocodile is fine though.
I'm also not sure whether type()
is the correct name for the method.
But IMO that method should definitely not return Object.keys(faker.animal)
or a subset thereof - or if it does we should have one that does not.
Would you consider adding additional animals to the definitions.animal.type which don't correspond to method names to be a breaking change?
Would you consider adding additional animals to the definitions.animal.type which don't correspond to method names to be a breaking change?
No, neither the jsdocs nor the implementation hint at it being a key of callable methods.
Also FR already has its own translations: https://github.com/faker-js/faker/blob/next/src/locales/fr/animal/type.ts
Then I think we could just add a bunch more simple animals to this method? It's common to use animals as placeholder names eg on google docs
Thank you for your feature proposal.
We marked it as "waiting for user interest" for now to gather some feedback from our community:
If you would like to see this feature be implemented, please react to the description with an up-vote (:+1:).
If you have a suggestion or want to point out some special cases that need to be considered, please leave a comment, so we are aware about them.
We would also like to hear about other community members' use cases for the feature to give us a better understanding of their potential implicit or explicit requirements.
We will start the implementation based on:
the number of votes (:+1:) and comments
the relevance for the ecosystem
availability of alternatives and workarounds
and the complexity of the requested feature
We do this because:
There are plenty of languages/countries out there and we would like to ensure that every method can cover all or almost all of them.
Every feature we add to faker has "costs" associated to it:
Clear and concise description of the problem
Hi! I just want a method that returns an animal, of any type. Sometimes you just want any kind of animal rather than one of a specific species.
Suggested solution
maybe something like
Alternative
No response
Additional context
No response