@toolz/allow
Advanced tools
Comparing version 1.1.2 to 1.1.3
{ | ||
"name": "@toolz/allow", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"description": "Provides validation of data types", | ||
@@ -58,4 +58,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@toolz/is-a-regular-object": "^1.0.1" | ||
"@toolz/is-a-regular-object": "^1.0.1", | ||
"@toolz/local-storage-is-available": "^1.0.0" | ||
} | ||
} |
import { isARegularObject } from '@toolz/is-a-regular-object'; | ||
import { localStorageIsAvailable } from '@toolz/local-storage-is-available'; | ||
const localStorageIsSupported = () => { | ||
try { | ||
const testKey = '__some_random_key_you_are_not_going_to_use__'; | ||
localStorage.setItem(testKey, testKey); | ||
localStorage.removeItem(testKey); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
const Allow = () => { | ||
@@ -22,3 +12,3 @@ let allowNull; | ||
}; | ||
if (localStorageIsSupported()) { | ||
if (localStorageIsAvailable()) { | ||
const savedAllowNull = localStorage.getItem('allow.allowNull'); | ||
@@ -230,3 +220,3 @@ allowNull = savedAllowNull === 'true'; | ||
aBoolean(newAllowNull); | ||
if (localStorageIsSupported()) | ||
if (localStorageIsAvailable()) | ||
localStorage.setItem('allow.allowNull', newAllowNull.toString()); | ||
@@ -238,3 +228,3 @@ allowNull = newAllowNull; | ||
oneOf(behavior, failureBehavior); | ||
if (localStorageIsSupported()) | ||
if (localStorageIsAvailable()) | ||
localStorage.setItem('allow.failureBehavior', behavior); | ||
@@ -241,0 +231,0 @@ currentFailureBehavior = behavior; |
83965
2
1152
+ Added@toolz/local-storage-is-available@1.0.0(transitive)