|
| 1 | +/* eslint-disable implicit-arrow-linebreak */ |
| 2 | +/* eslint-disable operator-linebreak */ |
1 | 3 | const fs = require('fs');
|
2 | 4 |
|
3 | 5 | const obtenerUsuariosIncorrectos = (fileName) => {
|
4 | 6 | let results = [];
|
5 | 7 | try {
|
6 |
| - const text = fs.readFileSync(`./2022/01-arregla-twitter/${fileName}`, 'utf8'); |
7 |
| - const arr = text.toString().split(/\n\s*\n/).map((el) => el.replace(/\n/g, ' ')); |
8 |
| - results = arr.filter((data) => data.includes('usr:') |
9 |
| - && data.includes('eme:') |
10 |
| - && data.includes('psw:') |
11 |
| - && data.includes('age:') |
12 |
| - && data.includes('loc:') |
13 |
| - && data.includes('fll:')); |
14 |
| - return `submit: ${results.length}${results.at(-1)}`; |
| 8 | + const text = fs.readFileSync( |
| 9 | + `./2022/01-arregla-twitter/${fileName}`, |
| 10 | + 'utf8', |
| 11 | + ); |
| 12 | + const arr = text |
| 13 | + .toString() |
| 14 | + .split(/\n\s*\n/) |
| 15 | + .map((el) => el.replace(/\n/g, ' ')); |
| 16 | + results = arr.filter( |
| 17 | + (data) => |
| 18 | + data.includes('usr:') && |
| 19 | + data.includes('eme:') && |
| 20 | + data.includes('psw:') && |
| 21 | + data.includes('age:') && |
| 22 | + data.includes('loc:') && |
| 23 | + data.includes('fll:'), |
| 24 | + ); |
| 25 | + return `submit: ${results.length}${results |
| 26 | + .at(-1) |
| 27 | + .replace(/\s/g, ' ') |
| 28 | + .replace(/\s{2,}/g, ' ') |
| 29 | + .trim()}`; |
15 | 30 | } catch (e) {
|
16 |
| - return `Error: ${e.message}`; |
| 31 | + return `Error: when reading file ${fileName}`; |
17 | 32 | }
|
18 | 33 | };
|
19 | 34 |
|
|
0 commit comments