Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heldrida/array-to-txt-file
Takes in an array and will write each value to a text file. Each value is force-converted toString(), and concatenated with a newline.
https://github.com/heldrida/array-to-txt-file
Last synced: about 1 month ago
JSON representation
Takes in an array and will write each value to a text file. Each value is force-converted toString(), and concatenated with a newline.
- Host: GitHub
- URL: https://github.com/heldrida/array-to-txt-file
- Owner: heldrida
- Created: 2017-05-09T16:44:25.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-10T12:24:46.000Z (almost 8 years ago)
- Last Synced: 2024-12-30T10:18:54.466Z (about 2 months ago)
- Language: JavaScript
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# array-to-txt-file
takes in an array and will write each value to a text file.
Each value is force-converted toString(), and concatenated with a newline.
Objects are written via JSON.stringify output.## Install
$ npm install array-to-txt-file## Example
```
const arrayToTxtFile = require('array-to-txt-file')arrayToTxtFile(['Hi there', function add(a,b) {return a+b}, {a: 1, b: 2, c: {d: 3}}], './test-output.txt', err => {
if(err) {
console.error(err)
return
}
console.log('Successfully wrote to txt file')
})
```
```
test-output.txt:Hi there
function add(a,b) {return a+b}
{"a":1,"b":2,"c":{"d":3}}
```## Unit tests
$ npm test