JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 16118
  • Score
    100M100P100Q132263F
  • License Apache-2.0 OR MIT

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

Package Exports

  • files-from-path

Readme

files-from-path

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

Build JavaScript Style Guide Downloads

Install

npm install files-from-path

Usage

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)

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

{
  name: String
  stream (): ReadableStream<Uint8Array>
  size: number
}

Releasing

You can publish by either running npm publish in the dist directory or using npx ipjs publish.

Contributing

Feel free to join in. All welcome. Please open an issue!

License

Dual-licensed under Apache 2.0 OR MIT