jkroso / parse-duration

convert a human readable duration to ms
MIT License
243 stars 37 forks source link

types flexibility #25

Closed prairir closed 3 years ago

prairir commented 4 years ago

the current type system is not as flexible as parsing.

doing

var parseDuration = require("parse-duration@0.4.0")

console.log(parseDuration('10 seconds', 'seconds'))

will print NaN but doing

var parseDuration = require("parse-duration@0.4.0")

console.log(parseDuration('10 seconds', 's'))

will print 10, the correct answer.

I believe that the unit types should be as flexible as the parsing types as not having it that way can lead to errors and weirdness.

dy commented 3 years ago

Fixed in v1.0