mirror of
https://github.com/disposable-email-domains/disposable-email-domains.git
synced 2024-12-12 09:54:39 +08:00
Adding Nodejs example usage + parser
This commit is contained in:
parent
7a93bd41ac
commit
f1cf93c7a5
27
README.md
27
README.md
@ -57,6 +57,33 @@ def reject_email_blacklist
|
||||
end
|
||||
end
|
||||
```
|
||||
**NodeJs ** contributed by @martin-fogelman
|
||||
```Node
|
||||
'use strict';
|
||||
|
||||
const readline = require('readline'),
|
||||
fs = require('fs');
|
||||
|
||||
const input = fs.createReadStream('./disposable_email_blacklist.conf'),
|
||||
output = [],
|
||||
rl = readline.createInterface({input});
|
||||
|
||||
// PROCESS LINES
|
||||
rl.on('line', (line) => {
|
||||
console.log(`Processing line ${output.length}`);
|
||||
output.push(line);
|
||||
});
|
||||
|
||||
// SAVE AS JSON
|
||||
rl.on('close', () => {
|
||||
try {
|
||||
const json = JSON.stringify(output);
|
||||
fs.writeFile('disposable_email_blacklist.json', json, () => console.log('--- FINISHED ---'));
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Contributing
|
||||
============
|
||||
|
Loading…
Reference in New Issue
Block a user