Skip to content

Commit e1f4e3a

Browse files
committed
feat: add typescript definitions
1 parent dd6953a commit e1f4e3a

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

index.d.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,11 @@ declare module '@isomorphic-git/lightning-fs' {
206206
* @returns The size of a file or directory in bytes.
207207
*/
208208
du(filepath: string): Promise<number>
209+
/**
210+
* Function that saves anything that need to be saved in IndexedBD or custom IDB object. Right now it saves SuperBlock so it's save to dump the object as dump it into a file (e.g. from a Browser)
211+
* @returns Promise that resolves when super block is saved to file
212+
*/
213+
flush(): Promise<void>
209214
}
210215

211216
export interface Options {
@@ -245,8 +250,19 @@ declare module '@isomorphic-git/lightning-fs' {
245250
* @default false
246251
*/
247252
defer?: boolean
248-
253+
db: FS.IDB
254+
}
255+
export interface IDB {
256+
constructor(dbname: string, storename: string): IDB
257+
saveSuperblock(sb: Uint8Array): TypeOrPromise<void>
258+
loadSuperblock(): TypeOrPromise<FS.SuperBlock>
259+
loadFile(inode: number): TypeOrPromise<Uint8Array>
260+
writeFile(inode: number, data: Uint8Array): TypeOrPromise<void>
261+
wipe(): TypeOrPromise<void>
262+
close(): TypeOrPromise<void>
249263
}
264+
type TypeOrPromise<T> = T | Promise<T>
265+
export type SuperBlock = Map<string | number, any>
250266
export interface MKDirOptions {
251267
/**
252268
* Posix mode permissions

0 commit comments

Comments
 (0)