node:fs
#Import
import fs from "nstdlib/node/fs";Note
Behaves like Node.js. Over a node:vfs memory mount. Paths outside a mount still throw.
#Support
- nstd: Gives the same output as Node.js in side-by-side tests: fs, fs-watch.
- Browser: Loads with a minimal
processobject. 103 of Node's 103 exports are available. 1 of 1 behavior checks match Node.js.
#Exports (105)
Every name Node.js exports from this module, and what you get when you read it, as a named import or as a property of the default import:
- ✅ A value, both ways. An export that throws an error naming the missing feature also counts.
- ⚠️ A value one way,
undefinedthe other. - ❔
undefinedboth ways. - ❌ Not exported at all.
- – Not measured.
Show all 105 exports
| Export | Node.js | Browser |
|---|---|---|
Dir | ✅ | ✅ |
Dirent | ✅ | ✅ |
FileReadStream | ✅ | ✅ |
FileWriteStream | ✅ | ✅ |
ReadStream | ✅ | ✅ |
Stats | ✅ | ✅ |
Utf8Stream | ✅ | ✅ |
WriteStream | ✅ | ✅ |
_toUnixTimestamp | ✅ | ✅ |
access | ✅ | ✅ |
accessSync | ✅ | ✅ |
appendFile | ✅ | ✅ |
appendFileSync | ✅ | ✅ |
chmod | ✅ | ✅ |
chmodSync | ✅ | ✅ |
chown | ✅ | ✅ |
chownSync | ✅ | ✅ |
close | ✅ | ✅ |
closeSync | ✅ | ✅ |
constants | ✅ | ✅ |
copyFile | ✅ | ✅ |
copyFileSync | ✅ | ✅ |
cp | ✅ | ✅ |
cpSync | ✅ | ✅ |
createReadStream | ✅ | ✅ |
createWriteStream | ✅ | ✅ |
exists | ✅ | ✅ |
existsSync | ✅ | ✅ |
fchmod | ✅ | ✅ |
fchmodSync | ✅ | ✅ |
fchown | ✅ | ✅ |
fchownSync | ✅ | ✅ |
fdatasync | ✅ | ✅ |
fdatasyncSync | ✅ | ✅ |
fstat | ✅ | ✅ |
fstatSync | ✅ | ✅ |
fsync | ✅ | ✅ |
fsyncSync | ✅ | ✅ |
ftruncate | ✅ | ✅ |
ftruncateSync | ✅ | ✅ |
futimes | ✅ | ✅ |
futimesSync | ✅ | ✅ |
glob | ✅ | ✅ |
globSync | ✅ | ✅ |
lchmod | ❔ | ❌ |
lchmodSync | ❔ | ❌ |
lchown | ✅ | ✅ |
lchownSync | ✅ | ✅ |
link | ✅ | ✅ |
linkSync | ✅ | ✅ |
lstat | ✅ | ✅ |
lstatSync | ✅ | ✅ |
lutimes | ✅ | ✅ |
lutimesSync | ✅ | ✅ |
mkdir | ✅ | ✅ |
mkdirSync | ✅ | ✅ |
mkdtemp | ✅ | ✅ |
mkdtempDisposableSync | ✅ | ✅ |
mkdtempSync | ✅ | ✅ |
open | ✅ | ✅ |
openAsBlob | ✅ | ✅ |
openAsBlobSync | ✅ | ✅ |
openSync | ✅ | ✅ |
opendir | ✅ | ✅ |
opendirSync | ✅ | ✅ |
promises | ✅ | ✅ |
read | ✅ | ✅ |
readFile | ✅ | ✅ |
readFileSync | ✅ | ✅ |
readSync | ✅ | ✅ |
readdir | ✅ | ✅ |
readdirSync | ✅ | ✅ |
readlink | ✅ | ✅ |
readlinkSync | ✅ | ✅ |
readv | ✅ | ✅ |
readvSync | ✅ | ✅ |
realpath | ✅ | ✅ |
realpathSync | ✅ | ✅ |
rename | ✅ | ✅ |
renameSync | ✅ | ✅ |
rm | ✅ | ✅ |
rmSync | ✅ | ✅ |
rmdir | ✅ | ✅ |
rmdirSync | ✅ | ✅ |
stat | ✅ | ✅ |
statSync | ✅ | ✅ |
statfs | ✅ | ✅ |
statfsSync | ✅ | ✅ |
symlink | ✅ | ✅ |
symlinkSync | ✅ | ✅ |
truncate | ✅ | ✅ |
truncateSync | ✅ | ✅ |
unlink | ✅ | ✅ |
unlinkSync | ✅ | ✅ |
unwatchFile | ✅ | ✅ |
utimes | ✅ | ✅ |
utimesSync | ✅ | ✅ |
watch | ✅ | ✅ |
watchFile | ✅ | ✅ |
write | ✅ | ✅ |
writeFile | ✅ | ✅ |
writeFileSync | ✅ | ✅ |
writeSync | ✅ | ✅ |
writev | ✅ | ✅ |
writevSync | ✅ | ✅ |
#Diagnostics
nstdlib running inside Node.js. This isn't an environment it's meant for, so it isn't shown above, but it tells a library problem from an environment one:
coverage: 105/105 of the host's export names answer inside host node. Behaviour verified against the host builtin. Over anode:vfsmemory mount. Paths outside a mount still throw.smoke: Imports in a clean child process.node-suite: 270/367 of Node's own eligible tests pass with ./dist inside host node. A failure there and in the page is the library's, one only in the page is the engine's.