Socket
Socket
Sign inDemoInstall

save-csv

Package Overview
Dependencies
0
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    save-csv

Download an array of objects as a CSV file in the browser


Version published
Weekly downloads
923
decreased by-12.26%
Maintainers
1
Install size
9.14 kB
Created
Weekly downloads
 

Readme

Source

save-csv

Download an array of objects as a CSV file in the browser

save-csv is a tiny library (892 bytes gzipped) that creates an CSV file from a array of objects with matching keys and triggers a download in the browser. Features:

  • Automatically detects the value separator (usually ,) based on the user's regional settings.
  • Saves UTF8 by default and helps Excel to recognize this by adding a byte order mark.
  • Fully configurable. Every output character can be modified via options.

Example

<script src="save-csv.min.js"></script>
saveCsv([
  {a:1, b:2},
  {a:3, b:4},
]);
Output
a,b
1,2
3,4

API

save-csv(array, [options])

  • array Array: An array containing objects with matching keys.
  • options Object
    • filename string: The filename to save to. Default: export.csv.
    • sep string: The value separator (usually ,). Recognizes the special value auto with which automatic detection based on the user's regional settings is attempted (See #1). Default: auto.
    • eol string: The line separator. Default: \r\n.
    • quote string: The quote character to use. Default: ".
    • bom boolean: Whether to include a byte order mark in the output. Default: true.
    • mime string: The mime type for the file. Default: text/csv;charset=utf-8.
    • formatter Function: A custom formatter function for values. The default function handles sep in values and uses JSON.stringify for complex values. Receives value`.

© silverwind, distributed under BSD licence

Keywords

FAQs

Last updated on 24 Nov 2018

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