yeow-api 0.3.8 → 0.3.9
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/package.json +1 -1
- package/src/core.ts +3 -1
- package/src/fs.ts +20 -1
package/package.json
CHANGED
package/src/core.ts
CHANGED
|
@@ -46,9 +46,11 @@ export {
|
|
|
46
46
|
readFile, readFileSync, readFileBase64, readFileBase64Sync,
|
|
47
47
|
writeFile, writeFileSync, writeFileBase64, writeFileBase64Sync,
|
|
48
48
|
appendFile, appendFileSync,
|
|
49
|
-
exists, existsSync,
|
|
49
|
+
exists, existsSync, stat, statSync,
|
|
50
|
+
isDirectory, isDirectorySync,
|
|
50
51
|
deleteFile, deleteFileSync, mkdir, mkdirSync, list, listSync,
|
|
51
52
|
} from './fs.js';
|
|
53
|
+
export type { FileStat } from './fs.js';
|
|
52
54
|
export { assets, read as assetsRead, readSync as assetsReadSync,
|
|
53
55
|
readBase64 as assetsReadBase64, readBase64Sync as assetsReadBase64Sync,
|
|
54
56
|
extract as assetsExtract, extractSync as assetsExtractSync,
|
package/src/fs.ts
CHANGED
|
@@ -69,6 +69,13 @@ function _makeFs(level: FsLevel) {
|
|
|
69
69
|
return r === true || String(r) === 'true';
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
+
async function stat(path: string): Promise<FileStat> {
|
|
73
|
+
return await _sendFsAsync({ t: t('stat'), p: { path } }) as FileStat;
|
|
74
|
+
}
|
|
75
|
+
function statSync(path: string): FileStat {
|
|
76
|
+
return _sendFs({ t: t('stat'), p: { path } }) as FileStat;
|
|
77
|
+
}
|
|
78
|
+
|
|
72
79
|
async function isDirectory(path: string): Promise<boolean> {
|
|
73
80
|
const r = await _sendFsAsync({ t: t('isDirectory'), p: { path } });
|
|
74
81
|
return r === true || String(r) === 'true';
|
|
@@ -130,7 +137,8 @@ function _makeFs(level: FsLevel) {
|
|
|
130
137
|
readFile, readFileSync, readFileBase64, readFileBase64Sync,
|
|
131
138
|
writeFile, writeFileSync, writeFileBase64, writeFileBase64Sync,
|
|
132
139
|
appendFile, appendFileSync,
|
|
133
|
-
exists, existsSync,
|
|
140
|
+
exists, existsSync, stat, statSync,
|
|
141
|
+
isDirectory, isDirectorySync,
|
|
134
142
|
deleteFile, deleteFileSync, mkdir, mkdirSync, list, listSync,
|
|
135
143
|
createReadStream, createWriteStream,
|
|
136
144
|
// outer 专属能力(systemPaths / getServerPath)
|
|
@@ -159,6 +167,8 @@ export const appendFile = fs.appendFile;
|
|
|
159
167
|
export const appendFileSync = fs.appendFileSync;
|
|
160
168
|
export const exists = fs.exists;
|
|
161
169
|
export const existsSync = fs.existsSync;
|
|
170
|
+
export const stat = fs.stat;
|
|
171
|
+
export const statSync = fs.statSync;
|
|
162
172
|
export const isDirectory = fs.isDirectory;
|
|
163
173
|
export const isDirectorySync = fs.isDirectorySync;
|
|
164
174
|
export const deleteFile = fs.deleteFile;
|
|
@@ -183,6 +193,15 @@ export interface WriteStreamOptions {
|
|
|
183
193
|
flags?: 'w' | 'a' | 'wx';
|
|
184
194
|
}
|
|
185
195
|
|
|
196
|
+
/** 文件状态(stat)。mtimeMs / ctimeMs 为 epoch 毫秒。 */
|
|
197
|
+
export interface FileStat {
|
|
198
|
+
isFile: boolean;
|
|
199
|
+
isDirectory: boolean;
|
|
200
|
+
size: number;
|
|
201
|
+
mtimeMs: number;
|
|
202
|
+
ctimeMs: number;
|
|
203
|
+
}
|
|
204
|
+
|
|
186
205
|
/** 文件读流:read() 一次返回一块(默认 1 MiB),null = EOF;可 for await。 */
|
|
187
206
|
export interface ReadStream {
|
|
188
207
|
read(maxBytes?: number): Promise<Uint8Array | null>;
|