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

file-selector

Package Overview
Dependencies
Maintainers
3
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

file-selector

Convert DataTransfer object to a list of File objects

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3.2M
decreased by-2.88%
Maintainers
3
Weekly downloads
 
Created

What is file-selector?

The file-selector npm package is a utility library for handling file selections in web applications. It provides functions to convert file selections into a standardized format for easier manipulation, including functions to handle selections from both file inputs and drag-and-drop operations.

What are file-selector's main functionalities?

Converting FileList to Array

This feature allows you to convert a FileList object, which is obtained from a file input element, into an array of files for easier iteration and manipulation.

import { fromFileList } from 'file-selector';

const inputElement = document.querySelector('input[type="file"]');
inputElement.addEventListener('change', async (event) => {
  const filesArray = await fromFileList(event.target.files);
  // Now you have an array of files
});

Handling Drag-and-Drop Files

This feature provides a way to handle files dropped into a dropzone on a webpage, converting the DataTransferItem list from the event into an array of files.

import { fromEvent } from 'file-selector';

const dropzone = document.getElementById('dropzone');
dropzone.addEventListener('drop', async (event) => {
  event.preventDefault();
  const items = await fromEvent(event);
  // Now you have an array of files from the drop event
});

Other packages similar to file-selector

Keywords

FAQs

Package last updated on 10 Oct 2024

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