# files-from-path

> Expand paths to file-like objects with name, readable stream and size.

Latest version **1.1.4** (published 2025-03-25) · Apache-2.0 OR MIT license · 0 weekly downloads

## Install

```sh
npm install files-from-path
pnpm add files-from-path
yarn add files-from-path
bun add files-from-path
```

## Health

**Score 45/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.4 |
| Published | 2025-03-25 |
| First published | 2021-07-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 OR MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18 |
| Dependencies | 1 |
| Unpacked size | 21.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 11 |
| Author | vasco-santos |
| Maintainers | alanshaw, vascosantos, it-dag-house |

## Links

- npm: https://www.npmjs.com/package/files-from-path
- Repository: https://github.com/storacha/files-from-path
- Homepage: https://github.com/storacha/files-from-path#readme
- Issues: https://github.com/storacha/files-from-path/issues
- npm.io page: https://npm.io/package/files-from-path

## Dependencies (1)

- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.10

## Recent versions

- 1.1.4 (latest) — 2025-03-25
- 1.1.5-rc.1 (next) — 2025-04-19
- 1.1.5-rc.0 — 2025-04-19
- 1.1.1 — 2024-11-15
- 1.0.4 — 2023-12-07
- 1.0.2 — 2023-11-20
- 1.0.1 — 2023-11-09
- 1.0.0 — 2023-03-14
- 0.2.6 — 2022-03-31
- 0.2.5 — 2022-03-24
- 0.2.4 — 2022-02-28
- 0.2.3 — 2022-01-11
- 0.2.2 — 2021-12-20
- 0.2.1 — 2021-09-01
- 0.2.0 — 2021-07-20
- … 4 more at https://npm.io/package/files-from-path/versions

## README

# files-from-path

> Expand paths to file-like objects with name, readable stream and size.

[![Build](https://github.com/storacha/files-from-path/actions/workflows/main.yml/badge.svg)](https://github.com/storacha/files-from-path/actions/workflows/main.yml)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Downloads](https://img.shields.io/npm/dm/files-from-path.svg)](https://www.npmjs.com/package/files-from-path)

## Install

```sh
npm install files-from-path
```

## Usage

```js
import { filesFromPaths } from 'files-from-path'

// Given a file system like:
// path/to/file.txt
// path/to/dir/a.pdf
// path/to/dir/images/cat.gif

const files = await filesFromPaths(['path/to/file.txt', 'path/to/dir'])
console.log(files)

// Output:
// [
//   { name: 'file.txt', stream: [Function: stream] },
//   { name: 'dir/b.pdf', stream: [Function: stream] },
//   { name: 'dir/images/cat.gif', stream: [Function: stream] },
// ]
// Note: common sub-path ("path/to/") is removed.
```

## API

### `filesFromPaths`

The following parameters can be provided to `filesFromPaths`:

| Name | Type | Description |
|------|------|-------------|
| paths | `Iterable<string>` | File system path(s) to read from |
| [options] | `object` | options |
| [options.hidden] | `boolean` | Include .dot files in matched paths (default: `false`) |
| [options.sort] | `boolean` | Sort files by path (default: `true`) |

It returns an _array_ of file-like objects in the form:

```ts
{
  name: string
  stream: () => ReadableStream<Uint8Array>
  size: number
}
```

## Releasing

Releasing to npm is done via [`release-please`](https://github.com/googleapis/release-please). A Release PR will be opened with a CHANGELOG update in after a PR is merged to main. Merging the release PR will publish the new version to npm.

## Contributing

Feel free to join in. All welcome. Please [open an issue](https://github.com/storacha/files-from-path/issues)!

## License

Dual-licensed under [Apache 2.0 OR MIT](https://github.com/storacha/files-from-path/blob/main/LICENSE.md)

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