Skip to content

Commit

Permalink
Update index.mjs
Browse files Browse the repository at this point in the history
  • Loading branch information
dy committed Jan 24, 2025
1 parent 18fe90a commit b33f5cc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ function parse(str = '', format = 'ms') {
else units = format
}
else units = units.toLowerCase()
units = parse[units] || parse[units.replace(/s$/, '')]
if (Object.prototype.hasOwnProperty.call(parse, units)) {
units = parse[units]
} else if (Object.prototype.hasOwnProperty.call(parse, units.replace(/s$/, ''))) {
units = parse[units.replace(/s$/, '')]
} else {
units = null
}
if (units) result = (result || 0) + Math.abs(parseFloat(n, 10)) * units, prevUnits = units
})

Expand Down

0 comments on commit b33f5cc

Please sign in to comment.