Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

files-from-path

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

files-from-path

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

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
3
Created
Source

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:

NameTypeDescription
pathsIterable<string>File system path(s) to read from
[options]objectoptions
[options.hidden]booleanInclude .dot files in matched paths (default: false)
[options.sort]booleanSort files by path (default: true)

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

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

Releasing

Releasing to npm is done via 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!

License

Dual-licensed under Apache 2.0 OR MIT

FAQs

Package last updated on 07 Dec 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc