diff options
author | Yoshiya Hinosawa <stibium121@gmail.com> | 2024-01-23 12:59:39 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-23 12:59:39 +0900 |
commit | 2af0c0a3c6ea017bef2481c1a1ce0806457d5427 (patch) | |
tree | ce75b5b9cc0d82d29526e4b47c1fd70bc94d27ae /ext/node/polyfills/_fs/_fs_readFile.ts | |
parent | 7e4145df253e234c188be33ece2ae21753bc19af (diff) |
fix(ext/node): fix no arg call of fs.promises.readFile (#22030)
Diffstat (limited to 'ext/node/polyfills/_fs/_fs_readFile.ts')
-rw-r--r-- | ext/node/polyfills/_fs/_fs_readFile.ts | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/node/polyfills/_fs/_fs_readFile.ts b/ext/node/polyfills/_fs/_fs_readFile.ts index 415d81a5b..7e231d8ec 100644 --- a/ext/node/polyfills/_fs/_fs_readFile.ts +++ b/ext/node/polyfills/_fs/_fs_readFile.ts @@ -18,7 +18,6 @@ import { Encodings, TextEncodings, } from "ext:deno_node/_utils.ts"; -import { promisify } from "ext:deno_node/internal/util.mjs"; function maybeDecode(data: Uint8Array, encoding: TextEncodings): string; function maybeDecode( @@ -91,11 +90,18 @@ export function readFile( } } -export const readFilePromise = promisify(readFile) as ( - & ((path: Path, opt: TextOptionsArgument) => Promise<string>) - & ((path: Path, opt?: BinaryOptionsArgument) => Promise<Buffer>) - & ((path: Path, opt?: FileOptionsArgument) => Promise<Buffer>) -); +export function readFilePromise( + path: Path, + options?: FileOptionsArgument | null | undefined, + // deno-lint-ignore no-explicit-any +): Promise<any> { + return new Promise((resolve, reject) => { + readFile(path, options, (err, data) => { + if (err) reject(err); + else resolve(data); + }); + }); +} export function readFileSync( path: string | URL, |