@naturalcycles/nodejs-lib 15.126.0 → 15.127.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fs/fs2.d.ts +3 -3
- package/dist/fs/fs2.js +4 -4
- package/package.json +1 -1
- package/src/fs/fs2.ts +9 -5
package/dist/fs/fs2.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RmOptions } from 'node:fs';
|
|
1
|
+
import type { RmOptions, WriteFileOptions } from 'node:fs';
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import fsp from 'node:fs/promises';
|
|
4
4
|
/**
|
|
@@ -22,8 +22,8 @@ declare class FS2 {
|
|
|
22
22
|
readBufferAsync(filePath: string): Promise<Buffer>;
|
|
23
23
|
readJson<T = unknown>(filePath: string): T;
|
|
24
24
|
readJsonAsync<T = unknown>(filePath: string): Promise<T>;
|
|
25
|
-
writeFile(filePath: string, data: string | Buffer): void;
|
|
26
|
-
writeFileAsync(filePath: string, data: string | Buffer): Promise<void>;
|
|
25
|
+
writeFile(filePath: string, data: string | Buffer, opt?: WriteFileOptions): void;
|
|
26
|
+
writeFileAsync(filePath: string, data: string | Buffer, opt?: WriteFileOptions): Promise<void>;
|
|
27
27
|
writeJson(filePath: string, data: any, opt?: JsonOptions): void;
|
|
28
28
|
writeJsonAsync(filePath: string, data: any, opt?: JsonOptions): Promise<void>;
|
|
29
29
|
appendFile(filePath: string, data: string | Buffer): void;
|
package/dist/fs/fs2.js
CHANGED
|
@@ -55,11 +55,11 @@ class FS2 {
|
|
|
55
55
|
const str = await fsp.readFile(filePath, 'utf8');
|
|
56
56
|
return _jsonParse(str);
|
|
57
57
|
}
|
|
58
|
-
writeFile(filePath, data) {
|
|
59
|
-
fs.writeFileSync(filePath, data);
|
|
58
|
+
writeFile(filePath, data, opt) {
|
|
59
|
+
fs.writeFileSync(filePath, data, opt);
|
|
60
60
|
}
|
|
61
|
-
async writeFileAsync(filePath, data) {
|
|
62
|
-
await fsp.writeFile(filePath, data);
|
|
61
|
+
async writeFileAsync(filePath, data, opt) {
|
|
62
|
+
await fsp.writeFile(filePath, data, opt);
|
|
63
63
|
}
|
|
64
64
|
writeJson(filePath, data, opt) {
|
|
65
65
|
const str = stringify(data, opt);
|
package/package.json
CHANGED
package/src/fs/fs2.ts
CHANGED
|
@@ -14,7 +14,7 @@ Credit to: fs-extra (https://github.com/jprichardson/node-fs-extra)
|
|
|
14
14
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
-
import type { RmOptions, Stats } from 'node:fs'
|
|
17
|
+
import type { RmOptions, Stats, WriteFileOptions } from 'node:fs'
|
|
18
18
|
import fs from 'node:fs'
|
|
19
19
|
import fsp from 'node:fs/promises'
|
|
20
20
|
import path from 'node:path'
|
|
@@ -65,12 +65,16 @@ class FS2 {
|
|
|
65
65
|
return _jsonParse(str)
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
writeFile(filePath: string, data: string | Buffer): void {
|
|
69
|
-
fs.writeFileSync(filePath, data)
|
|
68
|
+
writeFile(filePath: string, data: string | Buffer, opt?: WriteFileOptions): void {
|
|
69
|
+
fs.writeFileSync(filePath, data, opt)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
async writeFileAsync(
|
|
73
|
-
|
|
72
|
+
async writeFileAsync(
|
|
73
|
+
filePath: string,
|
|
74
|
+
data: string | Buffer,
|
|
75
|
+
opt?: WriteFileOptions,
|
|
76
|
+
): Promise<void> {
|
|
77
|
+
await fsp.writeFile(filePath, data, opt)
|
|
74
78
|
}
|
|
75
79
|
|
|
76
80
|
writeJson(filePath: string, data: any, opt?: JsonOptions): void {
|