Socialify

Folder ..

Viewing unique-values.js
28 lines (23 loc) • 972.0 B

 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
var blaver = require("../../index");

var emails = {};
var conflicts = 0;
// emails estimated: 1,055,881
// full names estimated: 1,185,139
for (var i = 0; i < 100000; i++) {
  // call function with no arguments
  var email = blaver.unique(blaver.internet.email);

  // or with function arguments as argument array
  // var email = blaver.unique(blaver.internet.email, [null, null, 'marak.com']);

  // or with custom options for maxTime as milliseconds or maxRetries
  // var email = blaver.unique(blaver.internet.email, [null, null, 'marak.com'], { maxRetries: 1, maxTime: 50 });

  if (typeof emails[email] === "undefined") {
    // found a unique new item
    emails[email] = true;
  } else {
    // found a conflicting item ( should not happen using blaver.unique() )
    conflicts++;
  }
}
console.log("total conflicts", conflicts); // should be zero using blaver.unique()
console.log("total uniques generated", Object.keys(emails).length);

// console.log(emails);