Socket
Socket
Sign inDemoInstall

js-file-download

Package Overview
Dependencies
0
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

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


Version published
Weekly downloads
528K
decreased by-0.37%
Maintainers
1
Created
Weekly downloads
 

Package description

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

Readme

Source

Javascript File Download

Javascript function to trigger browser to save data to file as if it was downloaded.

Installation

npm install js-file-download --save

Usage

var fileDownload = require('js-file-download');
fileDownload(data, 'filename.csv');

Keywords

FAQs

Last updated on 06 May 2020

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc