@travi/any
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -7,2 +7,3 @@ 'use strict'; | ||
var _ = _interopDefault(require('lodash')); | ||
var Chance = _interopDefault(require('chance')); | ||
@@ -66,14 +67,26 @@ | ||
var list = [], | ||
listSize = options.size || integer(Object.assign({}, DEFAULT_SIZE_RANGE, options)); | ||
var listSize = options.size || integer(Object.assign({}, DEFAULT_SIZE_RANGE, options)); | ||
for (var i = 0; i < listSize; i += 1) { | ||
list.push(factory()); | ||
if (options.uniqueOn) { | ||
var uniqueValues = {}; | ||
while (Object.keys(uniqueValues).length < listSize) { | ||
var item = factory(); | ||
uniqueValues[item[options.uniqueOn]] = item; | ||
} | ||
return _.values(uniqueValues); | ||
} else { | ||
var list = []; | ||
for (var i = 0; i < listSize; i += 1) { | ||
list.push(factory()); | ||
} | ||
return list; | ||
} | ||
return list; | ||
} | ||
function fromList(list) { | ||
return list[integer({ min: 0, max: list.length })]; | ||
return list[integer({ min: 0, max: list.length - 1 })]; | ||
} | ||
@@ -80,0 +93,0 @@ |
{ | ||
"name": "@travi/any", | ||
"version": "0.5.0", | ||
"version": "0.6.0", | ||
"description": "random data generator for when test data is insignificant", | ||
@@ -49,2 +49,3 @@ "main": "dist/any.js", | ||
"load-grunt-config": "0.19.2", | ||
"lodash": "4.13.1", | ||
"mocha": "2.5.3", | ||
@@ -51,0 +52,0 @@ "proxyquire": "1.7.10", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
8464
166
24