# fstream

> Advanced file system stream things

Latest version **1.0.12** (published 2019-05-15) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install fstream
pnpm add fstream
yarn add fstream
bun add fstream
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 1.0.12 |
| Published | 2019-05-15 |
| First published | 2011-11-01 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.6 |
| Dependencies | 4 |
| Unpacked size | 62 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 208 |
| Author | Isaac Z. Schlueter |
| Maintainers | iarna, isaacs, othiym23, zkat |

## Links

- npm: https://www.npmjs.com/package/fstream
- Repository: https://github.com/npm/fstream
- Homepage: https://github.com/npm/fstream#readme
- Issues: https://github.com/npm/fstream/issues
- npm.io page: https://npm.io/package/fstream

## Dependencies (4)

- [mkdirp](https://npm.io/package/mkdirp.md) >=0.5 0
- [rimraf](https://npm.io/package/rimraf.md) 2
- [inherits](https://npm.io/package/inherits.md) ~2.0.0
- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.1.2

## Recent versions

- 1.0.12 (latest) — 2019-05-15
- 1.0.11 — 2017-03-07
- 1.0.10 — 2016-06-17
- 1.0.9 — 2016-05-12
- 1.0.8 — 2015-09-10
- 1.0.7 — 2015-06-19
- 1.0.6 — 2015-05-08
- 1.0.5 — 2015-05-08
- 1.0.4 — 2015-01-24
- 1.0.3 — 2014-11-28
- 1.0.2 — 2014-08-19
- 0.1.31 — 2014-08-04
- 1.0.1 — 2014-08-01
- 1.0.0 — 2014-07-31
- 0.1.30 — 2014-07-31
- … 31 more at https://npm.io/package/fstream/versions

## README

Like FS streams, but with stat on them, and supporting directories and
symbolic links, as well as normal files.  Also, you can use this to set
the stats on a file, even if you don't change its contents, or to create
a symlink, etc.

So, for example, you can "write" a directory, and it'll call `mkdir`.  You
can specify a uid and gid, and it'll call `chown`.  You can specify a
`mtime` and `atime`, and it'll call `utimes`.  You can call it a symlink
and provide a `linkpath` and it'll call `symlink`.

Note that it won't automatically resolve symbolic links.  So, if you
call `fstream.Reader('/some/symlink')` then you'll get an object
that stats and then ends immediately (since it has no data).  To follow
symbolic links, do this: `fstream.Reader({path:'/some/symlink', follow:
true })`.

There are various checks to make sure that the bytes emitted are the
same as the intended size, if the size is set.

## Examples

```javascript
fstream
  .Writer({ path: "path/to/file"
          , mode: 0755
          , size: 6
          })
  .write("hello\n")
  .end()
```

This will create the directories if they're missing, and then write
`hello\n` into the file, chmod it to 0755, and assert that 6 bytes have
been written when it's done.

```javascript
fstream
  .Writer({ path: "path/to/file"
          , mode: 0755
          , size: 6
          , flags: "a"
          })
  .write("hello\n")
  .end()
```

You can pass flags in, if you want to append to a file.

```javascript
fstream
  .Writer({ path: "path/to/symlink"
          , linkpath: "./file"
          , SymbolicLink: true
          , mode: "0755" // octal strings supported
          })
  .end()
```

If isSymbolicLink is a function, it'll be called, and if it returns
true, then it'll treat it as a symlink.  If it's not a function, then
any truish value will make a symlink, or you can set `type:
'SymbolicLink'`, which does the same thing.

Note that the linkpath is relative to the symbolic link location, not
the parent dir or cwd.

```javascript
fstream
  .Reader("path/to/dir")
  .pipe(fstream.Writer("path/to/other/dir"))
```

This will do like `cp -Rp path/to/dir path/to/other/dir`.  If the other
dir exists and isn't a directory, then it'll emit an error.  It'll also
set the uid, gid, mode, etc. to be identical.  In this way, it's more
like `rsync -a` than simply a copy.

---
_Source: https://npm.io/package/fstream · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
