src/type/unit/physicalConstants.js
function unitFactory (name, valueStr, unitStr) {
  const dependencies = ['config', 'Unit', 'BigNumber']

  return factory(name, dependencies, ({ config, Unit, BigNumber }) => {
    // Note that we can parse into number or BigNumber.
    // We do not parse into Fractions as that doesn't make sense: we would lose precision of the values
    // Therefore we dont use Unit.parse()
    const value = config.number === 'BigNumber'
      ? new BigNumber(valueStr)
      : parseFloat(valueStr)

    const unit = new Unit(value, unitStr)
    unit.fixPrefix = true
    return unit
  })
}
function unitFactory (name, valueStr, unitStr) {
  const dependencies = ['config', 'Unit', 'BigNumber']

  return factory(name, dependencies, ({ config, Unit, BigNumber }) => {
    // Note that we can parse into number or BigNumber.
    // We do not parse into Fractions as that doesn't make sense: we would lose precision of the values
    // Therefore we dont use Unit.parse()
    const value = config.number === 'BigNumber'
      ? new BigNumber(valueStr)
      : parseFloat(valueStr)

    const unit = new Unit(value, unitStr)
    unit.fixPrefix = true
    return unit
  })
}
function unitFactory ( name , valueStr , unitStr ) { const dependencies = [ 'config' , 'Unit' , 'BigNumber' ] return factory ( name , dependencies , ( { config , Unit , BigNumber } ) => { // Note that we can parse into number or BigNumber. // We do not parse into Fractions as that doesn't make sense: we would lose precision of the values // Therefore we dont use Unit.parse() const value = config . number === 'BigNumber' ? new BigNumber ( valueStr ) : parseFloat ( valueStr ) const unit = new Unit ( value , unitStr ) unit . fixPrefix = true return unit } ) }
helper function to create a factory function which creates a physical constant, a Unit with either a number value or a BigNumber value depending on the configuration
helper function to create a factory function which creates a physical constant a Unit with either a number value or a BigNumber value depending on the configuration