@bouko/fs 0.0.1 → 0.0.3
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/functions/file.d.ts +2 -1
- package/dist/functions/file.js +5 -2
- package/package.json +2 -26
package/dist/functions/file.d.ts
CHANGED
|
@@ -21,5 +21,6 @@ type FileKind = keyof FileReturnMap;
|
|
|
21
21
|
type InferKind<P extends string> = P extends `${string}.mp3` ? "mp3" : P extends `${string}.json` ? "json" : never;
|
|
22
22
|
export declare function readFile<P extends string>(filePath: P, options?: EnsureFileOptions): Promise<FileReturnMap[InferKind<P>]>;
|
|
23
23
|
export declare function readFile<T extends FileKind>(filePath: string, options?: EnsureFileOptions): Promise<FileReturnMap[T]>;
|
|
24
|
-
export declare function
|
|
24
|
+
export declare function saveJsonFile(filePath: string, options: EnsureFileOptions): Promise<void>;
|
|
25
|
+
export declare function saveFile(filePath: string, data: Buffer): Promise<void>;
|
|
25
26
|
export {};
|
package/dist/functions/file.js
CHANGED
|
@@ -73,14 +73,17 @@ export async function readFile(filePath, options) {
|
|
|
73
73
|
artists: common.artists ?? (common.artist ? [common.artist] : []),
|
|
74
74
|
artwork: pic ? `data:${pic.format};base64,${Buffer.from(pic.data).toString("base64")}` : null
|
|
75
75
|
},
|
|
76
|
-
duration: format.duration
|
|
76
|
+
duration: format.duration ? Math.round(format.duration * 1000) : 0,
|
|
77
77
|
last_modified
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
80
|
throw new Error(`Unsupported file type: ${filePath}`);
|
|
81
81
|
}
|
|
82
|
-
export async function
|
|
82
|
+
export async function saveJsonFile(filePath, options) {
|
|
83
83
|
const dirPath = path.dirname(filePath);
|
|
84
84
|
await fs.mkdir(dirPath, { recursive: true });
|
|
85
85
|
await fs.writeFile(filePath, JSON.stringify(options.data, null, 2), "utf8");
|
|
86
86
|
}
|
|
87
|
+
export async function saveFile(filePath, data) {
|
|
88
|
+
await fs.writeFile(filePath, data);
|
|
89
|
+
}
|
package/package.json
CHANGED
|
@@ -1,58 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/fs",
|
|
4
|
-
|
|
5
|
-
"version": "0.0.1",
|
|
6
|
-
|
|
4
|
+
"version": "0.0.3",
|
|
7
5
|
"main": "./dist/index.js",
|
|
8
|
-
|
|
9
6
|
"types": "./dist/index.d.ts",
|
|
10
|
-
|
|
11
7
|
"license": "MIT",
|
|
12
|
-
|
|
13
8
|
"files": [
|
|
14
|
-
|
|
15
9
|
"dist"
|
|
16
|
-
|
|
17
10
|
],
|
|
18
|
-
|
|
19
11
|
"publishConfig": {
|
|
20
|
-
|
|
21
12
|
"access": "public"
|
|
22
|
-
|
|
23
13
|
},
|
|
24
|
-
|
|
25
14
|
"author": "",
|
|
26
|
-
|
|
27
15
|
"description": "",
|
|
28
|
-
|
|
29
16
|
"engines": {},
|
|
30
17
|
|
|
31
18
|
"scripts": {
|
|
32
|
-
|
|
33
19
|
"build": "tsc"
|
|
34
|
-
|
|
35
20
|
},
|
|
36
21
|
|
|
37
22
|
"dependencies": {
|
|
38
|
-
|
|
39
23
|
"@bouko/ts": "^0.4.7",
|
|
40
|
-
|
|
41
24
|
"fs": "^0.0.1-security",
|
|
42
|
-
|
|
43
25
|
"music-metadata": "^11.12.1",
|
|
44
|
-
|
|
45
26
|
"path": "^0.12.7"
|
|
46
|
-
|
|
47
27
|
},
|
|
48
28
|
|
|
49
29
|
"devDependencies": {
|
|
50
|
-
|
|
51
30
|
"@types/node": "^24.3.0",
|
|
52
|
-
|
|
53
31
|
"typescript": "^5.9.2"
|
|
54
|
-
|
|
55
32
|
}
|
|
56
33
|
|
|
57
|
-
}
|
|
58
|
-
|
|
34
|
+
}
|