Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / exotic   js

Repository URL to install this package:

Version: 2.0.8 

/ src / types / primitive / number / cast / fromIshToNumber.ts

import { fromIshToString } from '../../string/fromIshToString'
import { isNumber } from '../check/isNumber'

function fromIshToNumber(x: string | number) {
  /**
   * @todo
   * 10px -> 10
   * 10 -> 10
   * remove special characters (1 0 px -> 10)
   * return as Number data type
   */
  if (isNumber(x)) {
    return x
  }
  const validNumberString = fromIshToString(x)
  const formatNumber = validNumberString.replace(/[^0-9-.]+/, '')
  return +formatNumber
}

export { fromIshToNumber }
export default fromIshToNumber