devel-localstorage
Advanced tools
+10
-30
@@ -12,3 +12,3 @@ /** | ||
| let localStorage = { | ||
| let localStorage = { | ||
| /** | ||
@@ -19,3 +19,3 @@ * Takes an array and transforms it to a string for localStorage | ||
| */ | ||
| set: function (store, data) { | ||
| set: function(store, data) { | ||
| if (Array.isArray(data)) { | ||
@@ -31,35 +31,15 @@ localStorage.setItem(store, JSON.stringify(data)) | ||
| */ | ||
| get: function (store) { | ||
| get: function(store) { | ||
| var stringArray = localStorage.getItem(store) | ||
| var array = [] | ||
| try { array = JSON.parse(stringArray) } catch (e) {} | ||
| try { | ||
| array = JSON.parse(stringArray) | ||
| } catch (e) { | ||
| console.log(e) | ||
| } | ||
| return Array.isArray(array) ? array : [] | ||
| } | ||
| // | ||
| // filter: function (store, query, callback) { | ||
| // // TODO : filter function and use callback pattern | ||
| // // if (response) callback(undefined, response.response) | ||
| // // else callback('That command does not exist! To list basic commands execute <b>commands</b> (or <b>cmd</b>) in the cmd field below.') | ||
| // } | ||
| } | ||
| export default localStorage | ||
| // filterTodos: function (todos, showCompleted, search) { | ||
| // | ||
| // var filteredTodos = todos.filter((todo) => { | ||
| // return !todo.completed || showCompleted | ||
| // }) | ||
| // | ||
| // filteredTodos = filteredTodos.filter((todo) => { | ||
| // var text = todo.text.toLowerCase() | ||
| // return search.length === 0 || todo.text.indexOf(search) > - 1 | ||
| // }) | ||
| // | ||
| // filteredTodos.sort((a,b) => { | ||
| // if (!a.completed && b.completed) return - 1 | ||
| // else if (a.completed && !b.completed) return 1 | ||
| // else return 0 | ||
| // }) | ||
| // | ||
| // return filteredTodos | ||
| // } | ||
| export default localStorage |
+1
-1
| { | ||
| "name": "devel-localstorage", | ||
| "version": "1.0.9", | ||
| "version": "1.0.11", | ||
| "description": "A small library providing an API for localStorage", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
+2
-2
@@ -26,6 +26,6 @@ <!-- | ||
| // set | ||
| var res = localstorage.set('store',['devel','doe']) | ||
| var res = localStorage.set('store',['devel','doe']) | ||
| // get | ||
| var res = localstorage.get('store') | ||
| var res = localStorage.get('store') | ||
| ``` | ||
@@ -32,0 +32,0 @@ |
5862
-13.4%127
-14.19%