@prismatic-io/spectral
Advanced tools
Comparing version 7.3.2 to 7.3.3
@@ -204,2 +204,3 @@ "use strict"; | ||
* - `util.types.toNumber("", 5.5)` will return the default value `5.5`, since `value` was an empty string. | ||
* - `util.types.toNumber(null, 5.5)` will return the default value `5.5`, since `value` was `null`. | ||
* - `util.types.toNumber(undefined)` will return `0`, since `value` was undefined and no `defaultValue` was given. | ||
@@ -212,8 +213,8 @@ * - `util.types.toNumber("Hello")` will throw an error, since the string `"Hello"` cannot be coerced into a number. | ||
const toNumber = (value, defaultValue) => { | ||
if (typeof value === "undefined" || value === "" || value === null) { | ||
return defaultValue || 0; | ||
} | ||
if (isNumber(value)) { | ||
return Number(value); | ||
} | ||
if (typeof value === "undefined" || value === "") { | ||
return defaultValue || 0; | ||
} | ||
throw new Error(`Value '${value}' cannot be coerced to a number.`); | ||
@@ -220,0 +221,0 @@ }; |
{ | ||
"name": "@prismatic-io/spectral", | ||
"version": "7.3.2", | ||
"version": "7.3.3", | ||
"description": "Utility library for building Prismatic components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
156243
3488