Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#43: Handle a situation where the storage is not available #44

Merged
merged 2 commits into from
Feb 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ install:
script:
- yarn lint
- yarn build
- yarn test --coverage
after_script:
- yarn test
- yarn coveralls
2 changes: 1 addition & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "combo-storage",
"version": "2.0.0",
"version": "2.0.1",
"description": "The package allows you to manage data in LocalStorage, SessionStorage and Cookies",
"main": "dist/index.js",
"scripts": {
"build": "webpack --mode production",
"lint": "eslint --report-unused-disable-directives src",
"fix": "eslint --fix --report-unused-disable-directives src",
"test": "jest",
"coveralls": "jest --coverage && cat ./coverage/lcov.info | coveralls",
"coveralls": "cat ./coverage/lcov.info | coveralls",
"setup": "cp ./.github/hooks/pre-commit ./.git/hooks/pre-commit && chmod +x ./.git/hooks/pre-commit"
},
"repository": {
Expand Down
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import CookieComponent from './components/Cookie';
import StorageComponent from './components/Storage';

export const Cookie = new CookieComponent(document.cookie);
export const LocalStorage = new StorageComponent(localStorage);
export const SessionStorage = new StorageComponent(sessionStorage);
export const LocalStorage = typeof localStorage !== 'undefined' ? new StorageComponent(localStorage) : null;
export const SessionStorage = typeof sessionStorage !== 'undefined' ? new StorageComponent(sessionStorage) : null;