File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -183,22 +183,26 @@ class ByteUnitObject {
183183 }
184184
185185 add ( bytes ) {
186- this . checkInternalByteVal ( bytes ) ;
186+ if ( ! isParsable ( bytes ) ) throw Error ( '<bytes> argument must be a finite value' ) ;
187+ this . checkInternalByteVal ( ) ;
187188 return new ByteUnitObject ( this . bytes + parseByteOrByteArray ( bytes ) . reduce ( ( a , v ) => a + v , 0 ) ) ;
188189 }
189190
190191 subtract ( bytes ) {
191- this . checkInternalByteVal ( bytes ) ;
192+ if ( ! isParsable ( bytes ) ) throw Error ( '<bytes> argument must be a finite value' ) ;
193+ this . checkInternalByteVal ( ) ;
192194 return new ByteUnitObject ( this . bytes - parseByteOrByteArray ( bytes ) . reduce ( ( a , v ) => a + v , 0 ) ) ;
193195 }
194196
195197 multiply ( bytes ) {
196- this . checkInternalByteVal ( bytes ) ;
198+ if ( ! isParsable ( bytes ) ) throw Error ( '<bytes> argument must be a finite value' ) ;
199+ this . checkInternalByteVal ( ) ;
197200 return new ByteUnitObject ( this . bytes * parseByteOrByteArray ( bytes ) . reduce ( ( a , v ) => a * v , 1 ) ) ;
198201 }
199202
200203 divide ( bytes ) {
201- this . checkInternalByteVal ( bytes ) ;
204+ if ( ! isParsable ( bytes ) ) throw Error ( '<bytes> argument must be a finite value' ) ;
205+ this . checkInternalByteVal ( ) ;
202206 return new ByteUnitObject ( this . bytes / parseByteOrByteArray ( bytes ) . reduce ( ( a , v ) => a * v , 1 ) ) ;
203207 }
204208
You can’t perform that action at this time.
0 commit comments