forked from Varshneyhars/advanced-email-existence
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
56 lines (48 loc) · 2.19 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
let checkEmailExistence, checkMultipleEmails;
(async () => {
try {
if (typeof require !== 'undefined') {
// CommonJS environment
const moduleExports = require('./index.cjs');
checkEmailExistence = moduleExports.checkEmailExistence || moduleExports.default;
checkMultipleEmails = moduleExports.checkMultipleEmails || moduleExports.default;
} else {
// ES Module environment
const module = await import('./index.mjs');
checkEmailExistence = module.checkEmailExistence || module.default;
checkMultipleEmails = module.checkMultipleEmails || module.default;
}
// Example: Check single email
console.time('Single Email Check Time'); // Start timing single email check
const singleEmailResult = await checkEmailExistence('[email protected]');
console.timeEnd('Single Email Check Time'); // End timing and log the result
const { email, valid, undetermined } = singleEmailResult;
if (undetermined) {
console.log(`Email existence for ${email} is undetermined`);
} else if (valid) {
console.log(`Email ${email} exists`);
} else {
console.log(`Email ${email} does not exist`);
}
// Example: Check multiple emails
const emails = [
];
console.time('Multiple Email Check Time'); // Start timing multiple email check
const multipleResults = await checkMultipleEmails(emails);
console.timeEnd('Multiple Email Check Time'); // End timing and log the result
multipleResults.forEach(({ email, valid, undetermined }) => {
if (undetermined) {
console.log(`Email existence for ${email} is undetermined`);
} else if (valid) {
console.log(`Email ${email} exists`);
} else {
console.log(`Email ${email} does not exist`);
}
});
} catch (err) {
console.error('Error checking email existence:', err);
}
})();