npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@placemarkio/flat-drop-files

v1.0.2

Published

Flatten, normalize, and handle dropped files

Readme

@placemarkio/flat-drop-files

The Drag & Drop dataTransfer interface is powerful, but torturous. It has grown organically and via standards, and is full of footguns which make it trivially easy to mess up.

This is an attempt to make it all "just work." The input is a dataTransfer.items list, and the output is a normalized list of files, with a handle property that's a FileSystemFileHandle, and a path property that's a reconstructed relative file path.

This module takes care of:

  • Recursively collecting files within directories
  • Reassembling paths of nested files
  • Paging through directories with over 100 files
  • Ignoring junk files like .DS_Store

This is at the bleeding edge of the web, so there are some caveats.

  • TypeScript does not support FileSystemFileHandle objects yet. This module includes the @types/wicg-file-system-access module to polyfill that type until it is properly introduced.

Installation

This module is published on npm as @placemarkio/flat-drop-files.

Example

import { getFilesFromDataTransferItems } from "@placemarkio/flat-drop-files";

const zone = document.getElementById('zone');

zone.addEventListener("dragenter", (e) => {
  e.preventDefault();
});

zone.addEventListener("dragover", (e) => {
  e.preventDefault();
});

zone.addEventListener("drop", (e) => {
  e.preventDefault();
  getFilesFromDataTransferItems(e.dataTransfer.items).then(files => {
    console.log(files);
  });
});

Compatibility

This module is compatible with modern browsers: the baseline is browsers that support webkitGetAsEntry. It does not support IE11 or any other ancient browsers.

Ecosystem

The browser-fs-access module is highly recommended to work with the file objects returned by this module: with it, you can write back to the files using the file.handle property.

Source

This is inspired by datatransfer-files-promise, contains collected lessons from dropzone, and adapts its junk-file detection from Sindre Sorhus's excellent junk module.

Testing

This kind of module is exceptionally hard to test with automated tests. Thus, there's a manual test suite. Start the test suite with yarn start, which will boot up a local server, and follow the instructions, which involve dragging & dropping particular files and folders into the browser.

Comments

You'll find plenty of comments in index.ts about different gotchas and traps in the DataTransferItem, FileSystemEntry, and other APIs. It's unfortunately easy to get these things wrong, whether it's assuming that DataTransferItem.kind will correctly identify a directory, or forgetting to call readEntries on a directory reader repeatedly to page through each 100-item batch of files.