Skip to content

Conversation

VickyCrow
Copy link

This is my attempt to fix #54 that might help with the new upcoming release of ms. I don't have a lot of experience contributing to open source so it might not be the most optimal solution to the issue, but I'm open to suggestions.

The changes I've implemented redirect return NaN; to a new function multipleUnits that loops around the whole string and adds the resulting milliseconds with reduce, finding all substrings that match the number-unit format and using the parse function on them or returning NaN if no match is found or if sections of the string do not match the format.

For the time being, it allows multiple instances of the same unit and does not check if the time order of the units entered is correct. This is obviously not a professional solution, but I would need some help to figure out how to forbid such format. As expressed before, I take any suggestions regarding fixing this new issue.

Finally, I want to clarify I'm not experienced on testing, so I would like some opinions on the tests I added, their format and some other test that could be convenient.

Thank you for considering checking on my attempt.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Strings with multiple units return undefined
1 participant