Skip to content

Commit

Permalink
feat: update package
Browse files Browse the repository at this point in the history
  • Loading branch information
yuki committed Jan 20, 2023
1 parent 0249ca3 commit f2d8dca
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,7 @@
"url": "git+https://github.com/kokkorojs/jsondb.git"
},
"keywords": [
"kokkoro",
"json",
"database",
"db",
"local",
"store",
"storage"
"kokkoro"
],
"author": "yuki <mail@yuki.sh>",
"license": "MIT",
Expand All @@ -26,11 +20,9 @@
},
"homepage": "https://github.com/kokkorojs/jsondb#readme",
"devDependencies": {
"@kokkoro/utils": "^0.5.0",
"@types/node": "^18.11.18"
},
"dependencies": {
"@kokkoro/utils": "^0.2.1"
},
"files": [
"lib"
]
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

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

6 changes: 4 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export class Database {
constructor(path: string) {
path = isAbsolute(path) ? path : resolve(path);

let data = {};
// TODO /人◕ ‿‿ ◕人\ watch file
let need_refresh = false;

const filename = join(path, 'index.json');
const refreshData = (target: Record<string | symbol, any>) => {
const target_keys = Object.keys(target);
Expand Down Expand Up @@ -71,12 +75,10 @@ export class Database {
} catch (error) {
mkdirSync(path);
}
let data;

try {
data = require(filename);
} catch (error) {
data = {};
writeFileSync(filename, '{\n\n}');
}
return new Proxy(data, handler);
Expand Down

0 comments on commit f2d8dca

Please sign in to comment.