diff --git a/src/helpers/storage-utils.js b/src/helpers/storage-utils.js index 5e29a892..2d459ab8 100644 --- a/src/helpers/storage-utils.js +++ b/src/helpers/storage-utils.js @@ -1,4 +1,5 @@ import { nativeIsNaN } from './number-utils'; +import { logVerbose } from './log-utils'; /** * Sets item to a specified storage, if storage isn't full. @@ -23,13 +24,14 @@ export const setStorageItem = (storage, key, value, shouldLog) => { /** * Gets supported storage item value * @param {string} value input item value + * @param {boolean} verbose if logging invalid values is required * @returns {string|null|undefined|boolean} valid item value if ok OR null if not */ -export const getLimitedStorageItemValue = (value) => { +export const getLimitedStorageItemValue = (value, verbose) => { if (!value) { return null; } - const log = console.log.bind(console); // eslint-disable-line no-console + let validValue; if (value === 'undefined') { validValue = undefined; @@ -48,11 +50,11 @@ export const getLimitedStorageItemValue = (value) => { } else if (/^\d+$/.test(value)) { validValue = parseFloat(value); if (nativeIsNaN(validValue)) { - log(`Invalid storage item value: '${value}'`); + logVerbose(`Invalid storage item value: '${value}'`, verbose); return null; } if (Math.abs(validValue) > 0x7FFF) { - log(`Invalid storage item value: '${value}'`); + logVerbose(`Invalid storage item value: '${value}'`, verbose); return null; } } else if (value === 'yes') {