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

js-file-download

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-file-download

Javascript function that triggers browser to save javascript-generated content to a file

  • 0.4.12
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
611K
increased by7.1%
Maintainers
1
Weekly downloads
 
Created

What is js-file-download?

The js-file-download npm package is a simple utility for triggering file downloads in the browser. It allows developers to programmatically download files of various types, such as text, JSON, CSV, and more, directly from the client-side JavaScript code.

What are js-file-download's main functionalities?

Download Text File

This feature allows you to download a plain text file. The code sample demonstrates how to create a text file with the content 'Hello, world!' and trigger a download with the filename 'hello.txt'.

const fileDownload = require('js-file-download');
const text = 'Hello, world!';
fileDownload(text, 'hello.txt');

Download JSON File

This feature allows you to download a JSON file. The code sample shows how to convert a JavaScript object to a JSON string and trigger a download with the filename 'data.json'.

const fileDownload = require('js-file-download');
const jsonData = { name: 'John', age: 30 };
fileDownload(JSON.stringify(jsonData), 'data.json');

Download CSV File

This feature allows you to download a CSV file. The code sample demonstrates how to create a CSV string and trigger a download with the filename 'data.csv'.

const fileDownload = require('js-file-download');
const csvData = 'name,age\nJohn,30\nJane,25';
fileDownload(csvData, 'data.csv');

Other packages similar to js-file-download

Keywords

FAQs

Package last updated on 06 May 2020

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