Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seikho/linefeeds
Convert file line feeds using Node.JS
https://github.com/seikho/linefeeds
Last synced: 5 days ago
JSON representation
Convert file line feeds using Node.JS
- Host: GitHub
- URL: https://github.com/seikho/linefeeds
- Owner: Seikho
- Created: 2015-10-09T03:20:05.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-10-18T05:42:01.000Z (about 9 years ago)
- Last Synced: 2024-10-11T09:44:08.222Z (27 days ago)
- Language: JavaScript
- Size: 176 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Linefeeds
File line-endings conversion between CRLF and LF.
TypeScript definitions included (1.6+)### Installation
```
npm install linefeeds --save
```### Usage
Example:
```javascript
import lf = require('linefeeds');
import fs = require('fs');
var input = 'input.txt';/**
* Without no output provided, it will replace the input file
*/
var callback = error => console.log(error ? 'Failed to convert' : 'Successfully converted');// Synchronously convert to LF
lf.convertSync(input, { ending: lf.lf });// Asynchronously convert back to CRLF
lf.convert(input, { ending: lf.crlf }, callback);// Use a stream convert to LF again
var write = fs.createWriteStream('output.txt');
lf.stream(input, { ending: lf.lf }).pipe(write);
```Just want to convert a body of text that you already have in memory?
No problem!
```javascript
var text = 'some\nbody\nof\ntext';
var target = 'output.txt';// Asynchronously
lf.convertText(text, { ending: lf.crlf, target }, callback);// Synchronously
lf.convertTextSync(text, { ending: lf.crlf ,target });// Stream
var write = fs.createWriteStream(target);
lf.convertTextStream(text, { ending: lf.lf }).pipe(write);
```### License
MIT