isomorphic-git / lightning-fs

A lean and fast 'fs' for the browser
MIT License
493 stars 48 forks source link

Incorrect `IDB` interface #126

Open chuanqisun opened 5 months ago

chuanqisun commented 5 months ago

I noticed that current IDB interface had two errors:

  1. The constructor type was typed as a regular function
  2. The readFile was mis-typed as loadFile

/lightning-fs/index.d.ts

export interface IDB {
- constructor(dbname: string, storename: string): IDB
+ new (dbname: string, storename: string): IDB
  saveSuperblock(sb: Uint8Array): TypeOrPromise<void>
  loadSuperblock(): TypeOrPromise<FS.SuperBlock>
- loadFile(inode: number): TypeOrPromise<Uint8Array>
+ readFile(inode: number): TypeOrPromise<Uint8Array>
  writeFile(inode: number, data: Uint8Array): TypeOrPromise<void>
  wipe(): TypeOrPromise<void>
  close(): TypeOrPromise<void>
}
jcubic commented 5 months ago

Do you want to add a PR?

chuanqisun commented 5 months ago

See #127. Note that I removed the constructor instead of using new. I realized that my originally proposed fix was wrong as well and the constructor interface was unnecessary.