ClientStorage
Advanced tools
Comparing version 4.0.0 to 4.0.1
@@ -7,2 +7,6 @@ 'use strict'; | ||
var isServer = function () { | ||
return typeof process === 'object' && !process?.browser; | ||
}; | ||
var debug = function () { | ||
@@ -24,23 +28,28 @@ console.warn.apply(console, arguments); | ||
switch (driverName) { | ||
case 'localStorage': | ||
if (BrowserStorage.isSupported()) { | ||
StorageDriver = BrowserStorage; | ||
} else { | ||
debug('ClientStorage is set to "localStorage", but it is not supported on this browser'); | ||
} | ||
break; | ||
case 'cookies': | ||
if (CookiesStorage.isSupported()) { | ||
StorageDriver = CookiesStorage; | ||
} else { | ||
debug('ClientStorage is set to "cookies", but CookiesStorage is disabled on this browser'); | ||
} | ||
break; | ||
case 'js': | ||
if (isServer()) { | ||
StorageDriver = JSStorage; | ||
this.driverName = 'js'; | ||
break; | ||
default: | ||
break; | ||
} else { | ||
switch (driverName) { | ||
case 'localStorage': | ||
if (BrowserStorage.isSupported()) { | ||
StorageDriver = BrowserStorage; | ||
} else { | ||
debug('ClientStorage is set to "localStorage", but it is not supported on this browser'); | ||
} | ||
break; | ||
case 'cookies': | ||
if (CookiesStorage.isSupported()) { | ||
StorageDriver = CookiesStorage; | ||
} else { | ||
debug('ClientStorage is set to "cookies", but CookiesStorage is disabled on this browser'); | ||
} | ||
break; | ||
case 'js': | ||
StorageDriver = JSStorage; | ||
this.driverName = 'js'; | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
@@ -61,3 +70,7 @@ | ||
this.driver = new StorageDriver(this, document.cookie); | ||
if (this.driverName === 'cookies') { | ||
this.driver = new StorageDriver(this, document.cookie); | ||
} else { | ||
this.driver = new StorageDriver(this); | ||
} | ||
Object.assign(this, StorageDriver.prototype); | ||
@@ -64,0 +77,0 @@ } |
{ | ||
"name": "ClientStorage", | ||
"version": "4.0.0", | ||
"version": "4.0.1", | ||
"description": "Bulletproof persistent browser storage, works with disabled Cookies and/or localStorage", | ||
@@ -5,0 +5,0 @@ "main": "./client-storage.js", |
@@ -14,3 +14,4 @@ [![support](https://img.shields.io/badge/support-GitHub-white)](https://github.com/sponsors/dr-dimitru) | ||
- 👨💻 With `String`, `Array`, `Object`, and `Boolean` support as values; | ||
- ♿ Works with disabled `localStorage` and `cookies`. | ||
- ♿ Works with disabled `localStorage` and `cookies`; | ||
- Available via [📦 NPM](https://www.npmjs.com/package/ClientStorage) and [☄️ Atmosphere](https://atmospherejs.com/ostrio/cstorage). | ||
@@ -17,0 +18,0 @@ ![ClientStorage NPM library logo](https://raw.githubusercontent.com/VeliovGroup/Client-Storage/master/cover.jpg) |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
29953
513
205
0