( val )
| 11 | * @returns {void} |
| 12 | */ |
| 13 | const argumentIsNumeric = ( val ) => { |
| 14 | if ( typeof val === 'number' ) { |
| 15 | return true; |
| 16 | } |
| 17 | |
| 18 | if ( typeof val === 'string' ) { |
| 19 | return /^\d+$/.test( val ); |
| 20 | } |
| 21 | |
| 22 | if ( Array.isArray( val ) ) { |
| 23 | for ( let i = 0; i < val.length; i++ ) { |
| 24 | // Fail early if any argument isn't determined to be numeric |
| 25 | if ( ! argumentIsNumeric( val[ i ] ) ) { |
| 26 | return false; |
| 27 | } |
| 28 | } |
| 29 | return true; |
| 30 | } |
| 31 | |
| 32 | // If it's not an array, and not a string, and not a number, we don't |
| 33 | // know what to do with it |
| 34 | return false; |
| 35 | }; |
| 36 | |
| 37 | module.exports = argumentIsNumeric; |
no outgoing calls
no test coverage detected