Skip to content

Commit

Permalink
Update Env definitions (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
heineiuo authored May 22, 2020
1 parent ef4045f commit cbb2d45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
5 changes: 0 additions & 5 deletions port/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ export class NodeEnv implements Env {
}

writeFile = fs.promises.writeFile;
// @ts-ignore

readFile = fs.promises.readFile;
// @ts-ignore
open = fs.promises.open;
rename = fs.promises.rename;
unlink = fs.promises.unlink;
unlinkSync = fs.unlinkSync;
// @ts-ignore
fstat = fs.promises.fstat;

// eslint-disable-next-line
Expand All @@ -50,7 +46,6 @@ export class NodeEnv implements Env {

export class Database extends InternalDatabase {
constructor(dbpath: string, options: DatabaseOptions = {}) {
// @ts-ignore
if (!options.env) options.env = new NodeEnv();
super(dbpath, options);
}
Expand Down
12 changes: 5 additions & 7 deletions src/Env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
* LICENSE file in the root directory of this source tree.
*/

import { Buffer } from "./Buffer";

export interface Stats<T = number> {
isFile(): boolean;
isDirectory(): boolean;
Expand Down Expand Up @@ -119,7 +117,7 @@ export interface FileHandle {
*/
readFile(
options?: { encoding?: null; flag?: string | number } | null,
): Promise<Buffer>;
): Promise<Uint8Array>;

/**
* Asynchronously reads the entire contents of a file. The underlying file will _not_ be closed automatically.
Expand All @@ -144,7 +142,7 @@ export interface FileHandle {
| { encoding?: string | null; flag?: string | number }
| string
| null,
): Promise<string | Buffer>;
): Promise<string | Uint8Array>;

/**
* Asynchronous fstat(2) - Get file status.
Expand Down Expand Up @@ -235,13 +233,13 @@ export interface Env {
access(dbpath: string): Promise<void>;
mkdir(dbpath: string): Promise<void>;
rename(oldpath: string, newpath: string): Promise<void>;
readFile(dbpath: string): Promise<Buffer>;
readFile(dbpath: string): Promise<Uint8Array>;
readFile(
dbpath: string,
options?: { encoding?: string },
): Promise<string | Buffer>;
): Promise<string | Uint8Array>;
readFile(dbpath: string, bufferEncoding: "utf8"): Promise<string>;
writeFile(dbpath: string, content: Buffer | string): Promise<void>;
writeFile(dbpath: string, content: Uint8Array | string): Promise<void>;
open(dbpath: string, flag: string): Promise<FileHandle>;
unlink(filename: string): Promise<void>;
unlinkSync(filename: string): void;
Expand Down

0 comments on commit cbb2d45

Please sign in to comment.