Skip to content

Commit

Permalink
Delete redundant code. #13
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Dec 18, 2018
1 parent db84144 commit fff5d90
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions lib/main.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var storage = window.localStorage, even_storage = function () {};
var storage = window.localStorage;

function isJSON(obj) {
return typeof (obj) === "object" && Object.prototype.toString.call(obj).toLowerCase() === "[object object]" && !obj.length;
Expand Down Expand Up @@ -37,7 +37,6 @@ function Store() {

Store.prototype = {
set: function (key, val) {
even_storage('set', key, val);
if (key && !isJSON(key)) {
storage.setItem(key, stringify(val));
} else if (key && isJSON(key) && !val) {
Expand All @@ -57,16 +56,12 @@ Store.prototype = {
return deserialize(storage.getItem(key));
},
clear: function () {
this.forEach((key, val) => {
even_storage('clear', key, val);
});
storage.clear();
return this;
},
remove: function (key) {
var val = this.get(key);
storage.removeItem(key);
even_storage('remove', key, val);
return val;
},
has: function (key) { return ({}).hasOwnProperty.call(this.get(), key); },
Expand Down

0 comments on commit fff5d90

Please sign in to comment.