data_is-number.js

/**
 * @module isNumber
 * @description Determines if the specified variable (string or number) can be parsed as a number.
 * @param                 number
 *
 * @since 3.1.0
 *
 * @param {string|number} number The number variable to be checked.
 *
 * @return {boolean} Returns true if the specified variable is a number. Returns false otherwise.
 *
 * @example
 * import { isNumber } from "@gravityforms/utils";
 *
 * function Example() {
 * 	 let isnum = isNumber( 1.25 ); //yes
 * 	 isnum = isNumber( '3.5' ); //yes
 * 	 isnum = isNumber( '$3.5' ); //no
 * }
 *
 */
const isNumber = ( number ) => {
	return ! isNaN( parseFloat( number ) ) && isFinite( number );
};

export default isNumber;