mirror of
https://github.com/disposable-email-domains/disposable-email-domains.git
synced 2024-11-22 16:48:13 +08:00
update examples in readme (#381)
* update examples in readme * remove example for deno * add note for npm package
This commit is contained in:
parent
e483b503f1
commit
08fa776961
37
README.md
37
README.md
@ -116,36 +116,27 @@ end
|
|||||||
|
|
||||||
Alternatively you can use the `disposable_mail` gem: https://github.com/oesgalha/disposable_mail.
|
Alternatively you can use the `disposable_mail` gem: https://github.com/oesgalha/disposable_mail.
|
||||||
|
|
||||||
### NodeJs
|
### Node.js
|
||||||
contributed by [@martin-fogelman](https://github.com/martin-fogelman)
|
contributed by [@boywithkeyboard](https://github.com/boywithkeyboard)
|
||||||
|
|
||||||
```Node
|
```js
|
||||||
'use strict';
|
import { readFile } from 'node:fs/promises'
|
||||||
|
|
||||||
const readline = require('readline'),
|
let blocklist
|
||||||
fs = require('fs');
|
|
||||||
|
|
||||||
const input = fs.createReadStream('./disposable_email_blocklist.conf'),
|
async function isDisposable(email) {
|
||||||
output = [],
|
if (!blocklist) {
|
||||||
rl = readline.createInterface({input});
|
const content = await readFile('disposable_email_blocklist.conf', { encoding: 'utf-8' })
|
||||||
|
|
||||||
// PROCESS LINES
|
blocklist = content.split('\r\n').slice(0, -1)
|
||||||
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_blocklist.json', json, () => console.log('--- FINISHED ---'));
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
return blocklist.includes(email.split('@')[1])
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Alternatively you can use the [is-disposable library](https://github.com/boywithkeyboard/is-disposable).
|
||||||
|
|
||||||
### C#
|
### C#
|
||||||
```C#
|
```C#
|
||||||
private static readonly Lazy<HashSet<string>> _emailBlockList = new Lazy<HashSet<string>>(() =>
|
private static readonly Lazy<HashSet<string>> _emailBlockList = new Lazy<HashSet<string>>(() =>
|
||||||
|
Loading…
Reference in New Issue
Block a user