lib/node-utils.js
function (value, defaultValue) {
    if (module.exports.isEmpty(value)) {
      value = defaultValue
    } else if (typeof value === 'string') {
      value = value.trim().toLowerCase()
      switch (value) {
        case 'false':
          value = 0
          break
        case 'true':
          value = 1
          break
        default:
          value = Number(value)
      }
    } else if (typeof value === 'boolean') {
      value = Number(value)
    } else if (isNaN(value)) {
      value = NaN
    }
    return value
  }
function (value, defaultValue) {
    if (module.exports.isEmpty(value)) {
      value = defaultValue
    } else if (typeof value === 'string') {
      value = value.trim().toLowerCase()
      switch (value) {
        case 'false':
          value = 0
          break
        case 'true':
          value = 1
          break
        default:
          value = Number(value)
      }
    } else if (typeof value === 'boolean') {
      value = Number(value)
    } else if (isNaN(value)) {
      value = NaN
    }
    return value
  }
function ( value , defaultValue ) { if ( module . exports . isEmpty ( value ) ) { value = defaultValue } else if ( typeof value === 'string' ) { value = value . trim ( ) . toLowerCase ( ) switch ( value ) { case 'false' : value = 0 break case 'true' : value = 1 break default : value = Number ( value ) } } else if ( typeof value === 'boolean' ) { value = Number ( value ) } else if ( isNaN ( value ) ) { value = NaN } return value }
Convert the supplied value into a number.
@param value - The value to convert.
@param defaultValue - If the value parameter is undefined, null,
a zero-length string, or a string containing only whitespace characters,
the defaultValue is returned.
@returns The converted or default value. If the value parameter is
non-null, not a zero-length string, and not a string containing only
whitespace characters but cannot be converted to a number, NaN is
returned.
@private
Convert the supplied value into a number .