Socket
Socket
Sign inDemoInstall

@toolz/allow

Package Overview
Dependencies
1
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.1.1 to 1.1.2

5

package.json
{
"name": "@toolz/allow",
"version": "1.1.1",
"version": "1.1.2",
"description": "Provides validation of data types",

@@ -58,5 +58,4 @@ "keywords": [

"dependencies": {
"@toolz/is-a-regular-object": "^1.0.1",
"@toolz/local-storage": "^1.0.2"
"@toolz/is-a-regular-object": "^1.0.1"
}
}

32

src/allow.js
import { isARegularObject } from '@toolz/is-a-regular-object';
import { local } from '@toolz/local-storage';
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 = () => {
let allowNull = local.getItem('allow.allowNull', false);
let allowNull;
let currentFailureBehavior;
const failureBehavior = {

@@ -11,3 +22,10 @@ IGNORE: 'ignore',

};
let currentFailureBehavior = local.getItem('allow.failureBehavior', failureBehavior.THROW);
if (localStorageIsSupported()) {
const savedAllowNull = localStorage.getItem('allow.allowNull');
allowNull = savedAllowNull === 'true';
currentFailureBehavior = localStorage.getItem('allow.failureBehavior') || failureBehavior.THROW;
} else {
allowNull = false;
currentFailureBehavior = failureBehavior.THROW;
}
let onFailure = () => {

@@ -212,3 +230,5 @@ //

aBoolean(newAllowNull);
allowNull = local.setItem('allow.allowNull', newAllowNull);
if (localStorageIsSupported())
localStorage.setItem('allow.allowNull', newAllowNull.toString());
allowNull = newAllowNull;
};

@@ -218,3 +238,5 @@

oneOf(behavior, failureBehavior);
currentFailureBehavior = local.setItem('allow.failureBehavior', behavior);
if (localStorageIsSupported())
localStorage.setItem('allow.failureBehavior', behavior);
currentFailureBehavior = behavior;
};

@@ -221,0 +243,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc