We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
readFile
With this code:
import fs, { readFile, readFileSync } from "node:fs"; import fsPromises, { readFile as readFilePromise } from "node:fs/promises"; import { vol } from "memfs"; import { patchFs } from "fs-monkey"; vol.fromJSON({ "foo": "bar" }); patchFs(vol); const test = (fn) => { fn((err, data) => { if (err) { console.log(fn.toString().slice(8), "ERR"); } else { console.log(fn.toString().slice(8), "OK"); } }); }; const testSync = (fn) => { try { const data = fn(); console.log(fn.toString().slice(6), "OK"); } catch (err) { console.log(fn.toString().slice(6), "ERR"); } }; const testAsync = async (fn) => { try { const data = await fn(); console.log(fn.toString().slice(6), "OK"); } catch (err) { console.log(fn.toString().slice(6), "ERR"); } }; test((cb) => fs.readFile("foo", "utf8", cb)); test((cb) => fs.readFile("foo", cb)); test((cb) => readFile("foo", "utf8", cb)); test((cb) => readFile("foo", cb)); testSync(() => fs.readFileSync("foo", "utf8")); testSync(() => fs.readFileSync("foo")); testSync(() => readFileSync("foo", "utf8")); testSync(() => readFileSync("foo")); await testAsync(() => fs.promises.readFile("foo", "utf8")); await testAsync(() => fs.promises.readFile("foo")); await testAsync(() => fsPromises.readFile("foo", "utf8")); await testAsync(() => fsPromises.readFile("foo")); await testAsync(() => readFilePromise("foo", "utf8")); await testAsync(() => readFilePromise("foo"));
Only fs.readFile() and fs.readFileSync() work.
fs.readFile()
fs.readFileSync()
fs.readFile("foo", "utf8", cb)
fs.readFile("foo", cb)
readFile("foo", "utf8", cb)
readFile("foo", cb)
fs.readFileSync("foo", "utf8")
fs.readFileSync("foo")
readFileSync("foo", "utf8")
readFileSync("foo")
fs.promises.readFile("foo", "utf8")
fs.promises.readFile("foo")
fsPromises.readFile("foo", "utf8")
fsPromises.readFile("foo")
readFilePromise("foo", "utf8")
readFilePromise("foo")
I tested with and without "utf8" because the behavior can be different: nodejs/node#48658
"utf8"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
With this code:
Only
fs.readFile()
andfs.readFileSync()
work.fs.readFile("foo", "utf8", cb)
fs.readFile("foo", cb)
readFile("foo", "utf8", cb)
readFile("foo", cb)
fs.readFileSync("foo", "utf8")
fs.readFileSync("foo")
readFileSync("foo", "utf8")
readFileSync("foo")
fs.promises.readFile("foo", "utf8")
fs.promises.readFile("foo")
fsPromises.readFile("foo", "utf8")
fsPromises.readFile("foo")
readFilePromise("foo", "utf8")
readFilePromise("foo")
I tested with and without
"utf8"
because the behavior can be different: nodejs/node#48658The text was updated successfully, but these errors were encountered: