Closed prateek-budhiraja closed 1 year ago
Three quick thoughts from glancing at your PR:
You can make changes, push them to the repo, and then let me know again in Discord. Thanks! Great job.
Alternatively, we could export two named functions, generate
and count
, which would probably call a shared implementation function inside the module. That would be more natural syntax I think.
Alternatively, we could export two named functions,
generate
andcount
, which would probably call a shared implementation function inside the module. That would be more natural syntax I think.
I had doubts about count
and generate
, could you help me understand this better?
So count
would only return the number of words in the dictionary?
count
is used for that in index.d.tsWhat would generate
do? Would it be like count
, but with options such as minLength
and maxLength
, and then return a word value based on the options, like a word quantity filter? The name "generate" makes me think I am wrong about this question.
What I am saying is that if the module will be able to do more than one thing, that is either generate words or give you a count, then it should have two named exports, and no default export. It is often a mistake to assume there will only ever be one export from a module and now we have a chance to address that because this will be a new major version number anyway.
On Tue, May 9, 2023 at 10:22 AM nellfs @.***> wrote:
Alternatively, we could export two named functions, generate and count, which would probably call a shared implementation function inside the module. That would be more natural syntax I think.
I had doubts about count and generate, could you help me understand this better?
So count would only return the number of words in the dictionary?
- The name count is confusing to me because it makes me think that it only refers to the count of words that should be generated if it has no other parameter, count is used for that in index.d.ts https://github.com/apostrophecms/random-words/blob/11cc2291a56ccadbe5ce1f50f1c3f3e7cea4169e/index.d.ts#LL15C6-L15C6
What would generate do? Would it be like count, but with options such as minLength and maxLength, and then return a word value based on the options, like a word quantity filter? The name "generate" makes me think I am wrong about this question.
— Reply to this email directly, view it on GitHub https://github.com/apostrophecms/random-words/pull/37#issuecomment-1540227021, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAH27MAOXVXBHU4JFZWYA3XFJHJRANCNFSM6AAAAAAXMYTRV4 . You are receiving this because you commented.Message ID: @.***>
--
THOMAS BOUTELL | CHIEF TECHNOLOGY OFFICER APOSTROPHECMS | apostrophecms.com | he/him/his
Summary
dictionarySize: true
, it'll return the dictionary size only and not any random word! (even if used with other options)What are the specific steps to test this change?
Use the below code for testing
What kind of change does this PR introduce?
(Check at least one)
Make sure the PR fulfills these requirements:
If adding a new feature without an already open issue, it's best to open a feature request issue first and wait for approval before working on it.
Other information: