File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,18 +78,22 @@ class Vector {
7878 }
7979
8080 this . values = args ;
81- if ( ! Vector . friendlyErrorsDisabled ( ) && Array . isArray ( args ) ) {
81+ if ( Array . isArray ( args ) ) {
8282 for ( let i = 0 ; i < args . length ; i ++ ) {
8383 const v = args [ i ] ;
8484 if ( typeof v !== 'number' || ! Number . isFinite ( v ) ) {
85- this . _friendlyError (
86- 'Arguments contain non-finite numbers' ,
87- 'p5.Vector'
88- ) ;
85+ if ( ! Vector . friendlyErrorsDisabled ( ) ) {
86+ this . _friendlyError (
87+ 'Arguments contain non-finite numbers' ,
88+ 'p5.Vector'
89+ ) ;
90+ }
91+ this . values = [ ] ;
92+ break ;
8993 }
90- this . values = [ ] ;
91- break ;
9294 }
95+ } else {
96+ this . values = [ ] ;
9397 }
9498
9599 // This property is here where duck typing (checking if obj.isVector) needs
Original file line number Diff line number Diff line change @@ -43,16 +43,18 @@ export function _validatedVectorOperation(expectsSoloNumberArgument){
4343 args = new Array ( 3 ) . fill ( args [ 0 ] ) ;
4444 }
4545
46- if ( ! Vector . friendlyErrorsDisabled ( ) && Array . isArray ( args ) ) {
46+ if ( Array . isArray ( args ) ) {
4747 for ( let i = 0 ; i < args . length ; i ++ ) {
4848 const v = args [ i ] ;
4949 if ( typeof v !== 'number' || ! Number . isFinite ( v ) ) {
50- this . _friendlyError (
51- 'Arguments contain non-finite numbers' ,
52- 'p5.Vector'
53- ) ;
50+ if ( ! Vector . friendlyErrorsDisabled ( ) ) {
51+ this . _friendlyError (
52+ 'Arguments contain non-finite numbers' ,
53+ 'p5.Vector'
54+ ) ;
55+ return this ;
56+ }
5457 }
55- return this ;
5658 }
5759 }
5860
You can’t perform that action at this time.
0 commit comments