Skip to content

Commit 705ece3

Browse files
authored
refactor: use fs/promises instead of fs-extra (#530)
1 parent c4e017c commit 705ece3

File tree

8 files changed

+163
-196
lines changed

8 files changed

+163
-196
lines changed

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,27 +139,31 @@ db.set("key", "value", false); // Don't update the timestamp
139139
140140
### Import / Export
141141

142-
Importing JSON files can be done this way:
142+
Importing structured data into the database can be done the following way:
143143
```ts
144-
// pass a filename, the import will be asynchronous
145-
await db.importJson(filename);
146144
// pass the object directly, the import will be synchronous
147-
db.importJson({key: "value"});
145+
db.importJSON({key: "value"});
148146
```
149-
In both cases, existing entries in the DB will not be deleted but will be overwritten if they exist.
147+
Existing entries in the DB will not be deleted but will be overwritten if they exist.
150148

151-
Exporting JSON files is also possible:
149+
Exporting the data as a JSON object is also possible:
152150
```ts
153-
await db.exportJson(filename[, options]);
151+
const json = db.toJSON();
154152
```
155-
The file will be overwritten if it exists. The 2nd options argument can be used to control the file formatting. Since `fs-extra`'s `writeJson` is used under the hood, take a look at that [method documentation](https://github.com/jprichardson/node-fs-extra/blob/master/docs/writeJson.md) for details on the options object.
156153

157154
## Changelog
158155

159156
<!--
160157
Placeholder for next release:
161158
### __WORK IN PROGRESS__
162159
-->
160+
### __WORK IN PROGRESS__
161+
* BREAKING: Drop support for Node.js versions older than v22 (#529)
162+
* BREAKING: Removed `exportJson` method in favor of `toJSON`
163+
* BREAKING: Renamed `importJson` method to `importJSON`. Importing from a file is no longer supported. Read the file yourself if you need this functionality.
164+
* Filesystem access is now done using the native `fs.promises` instead of `fs-extra`
165+
* The package is now a hybrid ESM/CJS package (#529)
166+
163167
### 3.1.1 (2024-01-25)
164168
* Reduced CPU load while idle (#475)
165169

package-lock.json

Lines changed: 8 additions & 22 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"@commitlint/cli": "^20.1.0",
4646
"@commitlint/config-conventional": "^20.0.0",
4747
"@tsconfig/node22": "^22.0.2",
48-
"@types/fs-extra": "^9.0.13",
4948
"@types/node": "^22.18.8",
5049
"@types/proper-lockfile": "^4.1.2",
5150
"@vitest/coverage-istanbul": "^3.2.4",
@@ -64,8 +63,7 @@
6463
},
6564
"dependencies": {
6665
"@alcalzone/proper-lockfile": "^4.1.3-0",
67-
"alcalzone-shared": "^5.0.0",
68-
"fs-extra": "^10.1.0"
66+
"alcalzone-shared": "^5.0.0"
6967
},
7068
"overrides": {
7169
"[email protected]": "^1.2.6"

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export { FsWriteOptions, JsonlDB, JsonlDBOptions } from "./lib/db.js";
1+
export { JsonlDB, JsonlDBOptions } from "./lib/db.js";

0 commit comments

Comments
 (0)