UNPKG

858 BJavaScriptView Raw
1var uniqueExec = require('../vendor/unique');
2/**
3 *
4 * @namespace faker.unique
5 */
6function Unique (faker) {
7
8 // initialize unique module class variables
9
10 // maximum time unique.exec will attempt to run before aborting
11 var maxTime = 10;
12
13 // maximum retries unique.exec will recurse before abortings ( max loop depth )
14 var maxRetries = 10;
15
16 // time the script started
17 // var startTime = 0;
18
19 /**
20 * unique
21 *
22 * @method unique
23 */
24 this.unique = function unique (method, args, opts) {
25 opts = opts || {};
26 opts.startTime = new Date().getTime();
27 if (typeof opts.maxTime !== 'number') {
28 opts.maxTime = maxTime;
29 }
30 if (typeof opts.maxRetries !== 'number') {
31 opts.maxRetries = maxRetries;
32 }
33 opts.currentIterations = 0;
34 return uniqueExec.exec(method, args, opts);
35 }
36}
37
38module['exports'] = Unique;
\No newline at end of file