Skip to content

Commit

Permalink
released v2.0.3 #41 #8
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Mar 29, 2023
1 parent 5bb6653 commit 8ed05fb
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 48 deletions.
32 changes: 19 additions & 13 deletions dist/store.cjs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* storejs v2.0.2
* storejs v2.0.3
* Local storage localstorage package provides a simple API
*
* Copyright (c) 2023 kenny wang <[email protected]>
Expand All @@ -10,7 +10,6 @@

'use strict';

var storage = window.localStorage;
function isJSON(obj) {
obj = JSON.stringify(obj);
if (!/^\{[\s\S]*\}$/.test(obj)) {
Expand Down Expand Up @@ -39,29 +38,36 @@ function isArray(value) {
}
// https://github.com/jaywcjlove/store.js/pull/8
// Error: QuotaExceededError
function dealIncognito(storage) {
function dealIncognito() {
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.localStorage;
var _KEY = '_Is_Incognit',
_VALUE = 'yes';
try {
storage.setItem(_KEY, _VALUE);
storage.removeItem(_KEY);
} catch (e) {
if (e.name === 'QuotaExceededError') {
var _nothing = function _nothing() {};
storage.__proto__ = {
setItem: _nothing,
getItem: _nothing,
removeItem: _nothing,
clear: _nothing
};
}
Storage.prototype._data = {};
Storage.prototype.setItem = function (id, val) {
return this._data[id] = String(val);
};
Storage.prototype.getItem = function (id) {
return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
};
Storage.prototype.removeItem = function (id) {
return delete this._data[id];
};
Storage.prototype.clear = function () {
return this._data = {};
};
storage = Storage;
} finally {
if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY);
}
return storage;
}

// deal QuotaExceededError if user use incognito mode in browser
storage = dealIncognito(storage);
var storage = dealIncognito();
function Store() {
if (!(this instanceof Store)) {
return new Store();
Expand Down
32 changes: 19 additions & 13 deletions dist/store.esm.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* storejs v2.0.2
* storejs v2.0.3
* Local storage localstorage package provides a simple API
*
* Copyright (c) 2023 kenny wang <[email protected]>
Expand All @@ -8,7 +8,6 @@
* Licensed under the MIT license.
*/

var storage = window.localStorage;
function isJSON(obj) {
obj = JSON.stringify(obj);
if (!/^\{[\s\S]*\}$/.test(obj)) {
Expand Down Expand Up @@ -37,29 +36,36 @@ function isArray(value) {
}
// https://github.com/jaywcjlove/store.js/pull/8
// Error: QuotaExceededError
function dealIncognito(storage) {
function dealIncognito() {
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.localStorage;
var _KEY = '_Is_Incognit',
_VALUE = 'yes';
try {
storage.setItem(_KEY, _VALUE);
storage.removeItem(_KEY);
} catch (e) {
if (e.name === 'QuotaExceededError') {
var _nothing = function _nothing() {};
storage.__proto__ = {
setItem: _nothing,
getItem: _nothing,
removeItem: _nothing,
clear: _nothing
};
}
Storage.prototype._data = {};
Storage.prototype.setItem = function (id, val) {
return this._data[id] = String(val);
};
Storage.prototype.getItem = function (id) {
return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
};
Storage.prototype.removeItem = function (id) {
return delete this._data[id];
};
Storage.prototype.clear = function () {
return this._data = {};
};
storage = Storage;
} finally {
if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY);
}
return storage;
}

// deal QuotaExceededError if user use incognito mode in browser
storage = dealIncognito(storage);
var storage = dealIncognito();
function Store() {
if (!(this instanceof Store)) {
return new Store();
Expand Down
32 changes: 19 additions & 13 deletions dist/store.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**!
* storejs v2.0.2
* storejs v2.0.3
* Local storage localstorage package provides a simple API
*
* Copyright (c) 2023 kenny wang <[email protected]>
Expand All @@ -14,7 +14,6 @@
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.store = factory());
})(this, (function () { 'use strict';

var storage = window.localStorage;
function isJSON(obj) {
obj = JSON.stringify(obj);
if (!/^\{[\s\S]*\}$/.test(obj)) {
Expand Down Expand Up @@ -43,29 +42,36 @@
}
// https://github.com/jaywcjlove/store.js/pull/8
// Error: QuotaExceededError
function dealIncognito(storage) {
function dealIncognito() {
var storage = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.localStorage;
var _KEY = '_Is_Incognit',
_VALUE = 'yes';
try {
storage.setItem(_KEY, _VALUE);
storage.removeItem(_KEY);
} catch (e) {
if (e.name === 'QuotaExceededError') {
var _nothing = function _nothing() {};
storage.__proto__ = {
setItem: _nothing,
getItem: _nothing,
removeItem: _nothing,
clear: _nothing
};
}
Storage.prototype._data = {};
Storage.prototype.setItem = function (id, val) {
return this._data[id] = String(val);
};
Storage.prototype.getItem = function (id) {
return this._data.hasOwnProperty(id) ? this._data[id] : undefined;
};
Storage.prototype.removeItem = function (id) {
return delete this._data[id];
};
Storage.prototype.clear = function () {
return this._data = {};
};
storage = Storage;
} finally {
if (storage.getItem(_KEY) === _VALUE) storage.removeItem(_KEY);
}
return storage;
}

// deal QuotaExceededError if user use incognito mode in browser
storage = dealIncognito(storage);
var storage = dealIncognito();
function Store() {
if (!(this instanceof Store)) {
return new Store();
Expand Down
4 changes: 2 additions & 2 deletions dist/store.min.js

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

8 changes: 1 addition & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storejs",
"version": "2.0.2",
"version": "2.0.3",
"description": "Local storage localstorage package provides a simple API",
"homepage": "https://jaywcjlove.github.io/store.js/",
"author": "kenny wang <[email protected]>",
Expand Down Expand Up @@ -32,12 +32,6 @@
"dist/*.js",
"types/index.d.ts"
],
"markdown-to-html": {
"reurls": {
"./README-zh.md": "index.zh.html",
"./README.md": "index.html"
}
},
"devDependencies": {
"@babel/cli": "^7.21.0",
"@babel/core": "^7.21.0",
Expand Down

0 comments on commit 8ed05fb

Please sign in to comment.