-
-
Notifications
You must be signed in to change notification settings - Fork 50
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
refactor: major API changes #42
Conversation
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.
Hey @Josh-Cena, thanks a bunch for the PR. I like it 🤘
It mostly LGTM but since we're changing the API, I would go a bit further (cf. ReadingTimeResults
) and I would change a few minor things.
ReadingTimeResults
I would even go further. I think we should just return seconds and that's it. Milliseconds don't make sense here and minutes can be derived easily as you mentioned.
So that would give us:
type ReadingTimeResults = {
time: number;
words: number;
};
Simple.
Minor changes
ReadingTimeResults
→ReadingTimeResult
since we only returning one result.wordCount
→coundWord
since it's a function, I prefer if it starts with a verb.- Unless you were thinking about adding more properties to
WordCountStats
in the future, I prefer if we keep things simple and just return the word count. - I don't have a super-strong opinion on this, but I generally prefer to use
type
for concrete types (ie. POJOs) andinterface
for abstract types (ie. to be inherited by aclass
).
PS: Could you add yourself to the contributors' section ❤️
I kept the
I am😉 On my plans are Apart from those, great suggestions, will address those |
Signed-off-by: Josh-Cena <sidachen2003@gmail.com>
Ping for @ngryman if we can settle on the API and merge this, we can release |
Hey @Josh-Cena, sorry again for the delay. I'll be more responsive now I'm finally home 🙂 |
No problem😄 Shall we release 2.0.0? Is there any other milestone on your mind? |
Yes! Out of precaution, I published it as a That will give us the time to potentially tweak things before the final Thanks for all the awesome work you did on this and sorry again for my lack of availability 🙏 |
Resolve #18.
Breaking changes
readingTime
now only returnstime
(milliseconds) andminutes
—both are integers. No strings or decimals are returned. You can always convert them to representations you need.text
improves ease of i18n as we are no longer biased towards English.minutes
used to return a decimal which is triviallytime / 60000
but with a lot of floating point funkiness.ReadingTimeStream
now only stores word count as its state—it is the equivalent ofcountWords()
, not the bulk ofreadingTime()
. Users still need to runreadingTimeWithCount()
to get the result.I may be cutting too many features here. Open to discussion.
Features
New functions
countWords
andreadingTimeWithCount
. Right nowWordCountResults = { total: number }
, but in the future we can havewhitespace
,punctuation
,CJK
,words
, etc., each with its ownwordPerMinute
setting when passed toreadingTimeWithCount
!