All files / lib unique.js

100% Statements 13/13
100% Branches 6/6
100% Functions 2/2
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

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 381x                   1x     1x                   1x 7x 7x 7x 5x   7x 5x   7x 7x       1x
var uniqueExec = require('../vendor/unique');
/**
 *
 * @namespace faker.unique
 */
function Unique (faker) {
 
  // initialize unique module class variables
 
  // maximum time unique.exec will attempt to run before aborting
  var maxTime = 10;
 
  // maximum retries unique.exec will recurse before abortings ( max loop depth )
  var maxRetries = 10;
 
  // time the script started
  // var startTime = 0;
 
  /**
   * unique
   *
   * @method unique
   */
  this.unique = function unique (method, args, opts) {
    opts = opts || {};
    opts.startTime = new Date().getTime();
    if (typeof opts.maxTime !== 'number') {
      opts.maxTime = maxTime;
    }
    if (typeof opts.maxRetries !== 'number') {
      opts.maxRetries = maxRetries;
    }
    opts.currentIterations = 0;
    return uniqueExec.exec(method, args, opts);
  }
}
 
module['exports'] = Unique;