First upload version 0.0.1
This commit is contained in:
13
node_modules/env-var/lib/accessors/float.js
generated
vendored
Normal file
13
node_modules/env-var/lib/accessors/float.js
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
'use strict'
|
||||
|
||||
module.exports = function asFloat (value) {
|
||||
const n = parseFloat(value)
|
||||
|
||||
// Some values are parsed as valid floats despite being obviously invalid, e.g. "1.o" or "192.168.1.1".
|
||||
// In these cases we would want to throw an error.
|
||||
if (isNaN(n) || isNaN(value)) {
|
||||
throw new Error('should be a valid float')
|
||||
}
|
||||
|
||||
return n
|
||||
}
|
||||
Reference in New Issue
Block a user