Handle CRLF for splitting lines on Windows
This commit is contained in:
@ -1761,7 +1761,7 @@ creating an array from contents of file by `split`ing file content line by line
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const readFileLines = filename => fs.readFileSync(filename).toString('UTF8').split('\n');
|
const readFileLines = filename => fs.readFileSync(filename).toString('UTF8').split(/\r?\n/);
|
||||||
/*
|
/*
|
||||||
contents of test.txt :
|
contents of test.txt :
|
||||||
line1
|
line1
|
||||||
|
|||||||
@ -8,7 +8,7 @@ creating an array from contents of file by `split`ing file content line by line
|
|||||||
|
|
||||||
```js
|
```js
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
const readFileLines = filename => fs.readFileSync(filename).toString('UTF8').split('\n');
|
const readFileLines = filename => fs.readFileSync(filename).toString('UTF8').split(/\r?\n/);
|
||||||
/*
|
/*
|
||||||
contents of test.txt :
|
contents of test.txt :
|
||||||
line1
|
line1
|
||||||
|
|||||||
Reference in New Issue
Block a user