Skip to content

Commit

Permalink
fix: get and parsing fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhodeep9 committed Nov 29, 2022
1 parent b02fd19 commit 47361fb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
14 changes: 11 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shubhodeep9/localstorm",
"version": "0.0.1",
"version": "0.0.2",
"description": "An ORM for localstorage",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -12,9 +12,17 @@
"orm",
"triggers"
],
"repository": {
"type": "git",
"url": "git+https://github.com/shubhodeep9/localstorm.git"
},
"author": "Shubhodeep Mukherjee",
"license": "ISC",
"license": "MIT",
"dependencies": {
"typescript": "^4.9.3"
}
},
"bugs": {
"url": "https://github.com/shubhodeep9/localstorm/issues"
},
"homepage": "https://github.com/shubhodeep9/localstorm#readme"
}
8 changes: 5 additions & 3 deletions src/entity/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,16 @@ export class Entry {
}
}

save(saveObj: any) {
save(saveObj: Object) {
this.validate(saveObj);

window.localStorage.setItem(this.key, saveObj);
window.localStorage.setItem(this.key, JSON.stringify(saveObj));
}

get() {
return window.localStorage.getItem(this.key);
const obj = window.localStorage.getItem(this.key);
if (!obj) return obj;
return JSON.parse(obj);
}

flush() {
Expand Down

0 comments on commit 47361fb

Please sign in to comment.