File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ module.exports = function(val, options) {
2828 var type = typeof val ;
2929 if ( type === 'string' && val . length > 0 ) {
3030 return parse ( val ) ;
31- } else if ( type === 'number' && isNaN ( val ) === false ) {
31+ } else if ( type === 'number' && isFinite ( val ) ) {
3232 return options . long ? fmtLong ( val ) : fmtShort ( val ) ;
3333 }
3434 throw new Error (
Original file line number Diff line number Diff line change @@ -283,4 +283,16 @@ describe('ms(invalid inputs)', function() {
283283 ms ( NaN ) ;
284284 } ) . to . throwError ( ) ;
285285 } ) ;
286+
287+ it ( 'should throw an error, when ms(Infinity)' , function ( ) {
288+ expect ( function ( ) {
289+ ms ( Infinity ) ;
290+ } ) . to . throwError ( ) ;
291+ } ) ;
292+
293+ it ( 'should throw an error, when ms(-Infinity)' , function ( ) {
294+ expect ( function ( ) {
295+ ms ( - Infinity ) ;
296+ } ) . to . throwError ( ) ;
297+ } ) ;
286298} ) ;
You can’t perform that action at this time.
0 commit comments