# extra-filesystem

> ```sh npm install --save extra-filesystem # or yarn add extra-filesystem ```

Latest version **0.6.2** (published 2026-02-28) · MIT license · 0 weekly downloads

## Install

```sh
npm install extra-filesystem
pnpm add extra-filesystem
yarn add extra-filesystem
bun add extra-filesystem
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.6.2 |
| Published | 2026-02-28 |
| First published | 2021-01-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=22 |
| Dependencies | 7 |
| Unpacked size | 71.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | BlackGlory |
| Maintainers | black_glory |

## Links

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

## Dependencies (7)

- [js-yaml](https://npm.io/package/js-yaml.md) ^4.1.1
- [fs-extra](https://npm.io/package/fs-extra.md) ^11.3.3
- [extra-utils](https://npm.io/package/extra-utils.md) ^5.20.0
- [tmp-promise](https://npm.io/package/tmp-promise.md) ^3.0.3
- [extra-promise](https://npm.io/package/extra-promise.md) ^7.0.1
- [iterable-operator](https://npm.io/package/iterable-operator.md) ^5.1.0
- [@blackglory/prelude](https://npm.io/package/@blackglory/prelude.md) ^0.4.0

## Recent versions

- 0.6.2 (latest) — 2026-02-28
- 0.6.1 — 2026-02-01
- 0.6.0 — 2026-01-31
- 0.5.2 — 2025-03-10
- 0.5.1 — 2023-06-10
- 0.5.0 — 2023-03-27
- 0.4.10 — 2023-01-26
- 0.4.9 — 2023-01-26
- 0.4.8 — 2022-11-23
- 0.4.7 — 2022-11-23
- 0.4.6 — 2022-10-22
- 0.4.5 — 2022-08-01
- 0.4.4 — 2022-07-10
- 0.4.3 — 2022-07-07
- 0.4.2 — 2022-03-07
- … 37 more at https://npm.io/package/extra-filesystem/versions

## README

# extra-filesystem
## Install
```sh
npm install --save extra-filesystem
# or
yarn add extra-filesystem
```

## API
### createTempDir
```ts
function createTempDir(): Promise<string>
```

### createTempDirSync
```ts
function createTempDirSync(): string
```

### createTempFile
```ts
function createTempFile(): Promise<string>
```

### createTempFileSync
```ts
function createTempFileSync(): string
```

### createTempName
```ts
function createTempName(): Promise<stirng>
```

### createTempNameSync
```ts
function createTempNameSync(): string
```

### emptyDir
```ts
function emptyDir(dirname: string): Promise<void>
```

### emptyDirSync
```ts
function emptyDirSync(dirname: string): void
```

### ensureDir
```ts
function ensureDir(dirname: string): Promise<void>
```

### ensureDirSync
```ts
function ensureDirSync(dirname: string): void
```

### ensureFile
```ts
function ensureFile(filename: string): Promise<void>
```

### ensureFileSync
```ts
function ensureFileSync(filename: string): void
```

### pathExists
```ts
function pathExists(path: string): Promise<boolean>
```

### pathExistsSync
```ts
function pathExistsSync(path: string): boolean
```

### readNDJSONFile
```ts
function readNDJSONFile<T>(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): AsyncIterableIterator<T>
```

### readNDJSONFileSync
```ts
function readNDJSONFileSync<T>(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): IterableIterator<T>
```

### readYAMLFile
```ts
function readYAMLFile<T>(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): Promise<T>
```

### readYAMLFileSync
```ts
function readYAMLFileSync<T>(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): T
```

### readJSONFile
```ts
function readJSONFile<T>(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): Promise<T>
```

### readJSONFileSync
```ts
function readJSONFileSync<T>(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): T
```

### writeJSONFile
```ts
function writeJSONFile(
  filename: string
, data: unknown
, options?: { spaces?: number }
): Promise<void>
```

### writeJSONFileSync
```ts
function writeJSONFileSync(
  filename: string
, data: unknown
, options?: { spaces?: number }
): void
```

### writeYAMLFile
```ts
function writeYAMLFile(filename: string, data: unknown): Promise<void>
```

### writeYAMLFileSync
```ts
function writeYAMLFileSync(filename: string, data: unknown): void
```

### move
```ts
function move(source: string, destination: string): Promise<void>
```

Move the file or directory from `source` to `destination`.

Unlike the `mv` command in Bash,
it does not support moving a file or directory to a directory.

If a file or directory already exists at the destination,
it will throw an error.

If the destination's parent directory does not exist,
it will create the parent directory.

### moveSync
```ts
function moveSync(source: string, destination: string): void
```

See `move()`.

### copy
```ts
function copy(source: string, destination: string): Promise<void>
```

Copy the file or directory from `source` to `destination`.

Unlike the `cp` command in Bash,
it does not support copying a file or directory to a directory.

If a file or directory already exists at the destination,
it will throw an error.

If the destination's parent directory does not exist,
it will create the parent directory.

### copySync
```ts
function copySync(source: string, destination: string): void
```

See `copy()`.

### remove
```ts
function remove(path: string): Promise<void>
```

### removeSync
```ts
function removeSync(path: string): void
```

### isDirectory
```ts
function isDirectory(path: string): Promise<boolean>
```

### isFile
```ts
function isFile(path: string): Promise<boolean>
```

### isWritable
```ts
function isWritable(path: string): Promise<boolean>
```

### isReadable
```ts
function isReadable(path: string): Promise<boolean>
```

### findAllFilenames
```ts
function findAllFilenames(
  dirname: string
, predicate: (dirname: string) => Awaitable<boolean> = _ => true
): AsyncIterableIterator<string>
```

### findAllDirnames
```ts
function findAllDirnames(
  dirname: string
, predicate: (dirname: string) => Awaitable<boolean> = _ => true
): AsyncIterableIterator<string>
```

### getLongExtension
```ts
function getLongExtension(filename: string): string
```

Get the longest possible extension.

```ts
getLongExtension('file.tar.gz') // '.tar.gz'
```

### getShortBasename
```ts
function getShortBasename(filename: string): string
```

Get the shortest possible basename.

```ts
getShortBasename('file.tar.gz') // 'file'
```

### readFileLineByLine
```ts
function readFileLineByLine(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): AsyncIterable<string>
```

### readFileLineByLineSync
```ts
function* readFileLineByLineSync(
  filename: string
, encoding: BufferEncoding = 'utf-8'
): IterableIterator<string>
```

### writeIterableToFile
```ts
function writeIterableToFile(
  filename: string
, iterable: Iterable<string> | AsyncIterable<string>
): Promise<void>
```

### isSubPathOf
```ts
function isSubPathOf(subject: string, object: string): boolean
```

### checksumFile
```ts
function checksumFile(algorithm: string, filename: string): Promise<string>
```

### findUpPackageFilename
```ts
function findUpPackageFilename(pathname: string): Promise<string | undefined>
```

### findUpPackageFilenameSync
```ts
function findUpPackageFilenameSync(pathname: string): string | undefined
```

### pathEquals
```ts
function pathEquals(a: string, b: string): boolean
```

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