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

html-dir-content

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-dir-content

(recursively) iterate directory entries in the browser (html5 File System API)

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
8.9K
increased by0.15%
Maintainers
1
Weekly downloads
 
Created
Source

HTML DIR CONTENT

(recursively) iterate directory entries in the browser (html5 File System API)

API

  • getFiles(item:DataTransferItem, options?: Options) : Promise<Array>

    Returns a promise of an array of files in case the provided item represents a directory and the FS API returns children files for it.

    • Options: Boolean | Object

      (In case of boolean value, it will be used for the recursive config)

      • recursive (default: false) - whether to recursively follow the dir structure
      • bail (default: 1000) - how many levels to follow recursively before bailing
  • getFilesFromDragEvent(evt: DragEvent, options?: Options)

    Returns a promise of an array of files for the given event. In case the event dataTransfer property contains file system entries and at least one of them is represents a directory and the FS API returns children files for it.

    • Options: Boolean | Object

      (In case of boolean value, it will be used for the recursive config)

      • recursive (default: false) - whether to recursively follow the dir structure
      • bail (default: 1000) - how many levels to follow recursively before bailing

note: The order of files returned is not guaranteed to be in same order the files on the file system or organized

Example

your HTML:

        <script src="dist/html-dir-content.min.js"></script>

your Javascript:


    window.addEventListener("drop", (e) => {
                e.preventDefault();
    
                htmlDirContent.getFilesFromDragEvent(e, true) //will perform recusrive traversal 
                    .then((files) => {
                        console.log("we have the files: ", files);
                    });
            });

You can drag a directory (ex: from File Explorer / Finder) and the resolved files array will contain the files contained within it and its sub folders

Dependencies

Requires global Promise object to be available

Works on all the latest browser versions (not IE11)

Keywords

FAQs

Package last updated on 17 Oct 2017

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