https://github.com/alrico88/data-exporter
Allows to save JSON formatted content to disk, as JSON or CSV in browsers
https://github.com/alrico88/data-exporter
browser csv download file json
Last synced: 12 months ago
JSON representation
Allows to save JSON formatted content to disk, as JSON or CSV in browsers
- Host: GitHub
- URL: https://github.com/alrico88/data-exporter
- Owner: alrico88
- Created: 2019-01-08T16:27:16.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-08-07T09:05:39.000Z (over 5 years ago)
- Last Synced: 2025-03-24T04:34:02.585Z (about 1 year ago)
- Topics: browser, csv, download, file, json
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/data-exporter
- Size: 34.2 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Classes
## Exporter
**Kind**: global class
- [Exporter](#Exporter)
- [new Exporter()](#new_Exporter_new)
- [.module.exports](#Exporter.module.exports)
- [new module.exports(data, filename, extension, mimeType)](#new_Exporter.module.exports_new)
- [.convertJSONToCsv(json)](#Exporter.convertJSONToCsv) ⇒ string
- [.stringifyJSON(json, [pretty])](#Exporter.stringifyJSON) ⇒ string
- [.save()](#Exporter.save)
- [.saveJSON()](#Exporter.saveJSON)
- [.saveCSV()](#Exporter.saveCSV)
### new Exporter()
Exporter class
### Exporter.module.exports
**Kind**: static class of [Exporter](#Exporter)
#### new module.exports(data, filename, extension, mimeType)
Creates an instance of Exporter.
| Param | Type | Description |
| --------- | ------------------- | ---------------------------------------------------------------- |
| data | any | Data to convert |
| filename | string | Filename for the resulting file |
| extension | string | Extension to use for the file. Use the EXTENSIONS enum as helper |
| mimeType | string | MIME expresssion. Use the MIMES enum as helper |
### Exporter.convertJSONToCsv(json) ⇒ string
Converts JSON to CSV
**Kind**: static method of [Exporter](#Exporter)
**Returns**: string - String representation of a CSV
| Param | Type | Description |
| ----- | -------------------------------------------------------- | ---------------------- |
| json | object \| Array.<object> | JSON to convert to CSV |
### Exporter.stringifyJSON(json, [pretty]) ⇒ string
Stringifies JSON
**Kind**: static method of [Exporter](#Exporter)
**Returns**: string - Stringified JSON
| Param | Type | Default | Description |
| -------- | -------------------------------------------------------- | ------------------ | --------------------------- |
| json | object \| Array.<object> | | JSON to stringify |
| [pretty] | boolean | false | Whether to use nice spacing |
### Exporter.save()
Triggers file download
**Kind**: static method of [Exporter](#Exporter)
### Exporter.saveJSON()
Shortcut to save as JSON
Processes JSON directly
**Kind**: static method of [Exporter](#Exporter)
### Exporter.saveCSV()
Shortcut to save as CSV
Processes JSON as CSV
**Kind**: static method of [Exporter](#Exporter)
## MIMES
## EXTENSIONS
**Kind**: global enum