chance-generators
Advanced tools
Comparing version 2.1.1 to 2.1.2
@@ -216,2 +216,6 @@ /*global define*/ | ||
unique: function (generator, data) { | ||
if (data.length === 0) { | ||
return that.constant(data) | ||
} | ||
var count = generator.args[1] | ||
@@ -225,7 +229,4 @@ if (count && count.shrink) { | ||
var dataGenerator = generator.args[0] | ||
if (dataGenerator.shrink) { | ||
return that.pickset(data.map(dataGenerator.shrink), count) | ||
} else { | ||
return that.pickset(data, count) | ||
} | ||
return that.unique(dataGenerator, count) | ||
}, | ||
@@ -232,0 +233,0 @@ shape: function (generator, data) { |
{ | ||
"name": "chance-generators", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Random generators based on changejs", | ||
@@ -5,0 +5,0 @@ "main": "lib/chance-generators.js", |
@@ -302,2 +302,14 @@ /*global describe, it*/ | ||
}) | ||
describe('shrink', () => { | ||
it('returns a new generator generating smaller unique sets', () => { | ||
let generator = chance.unique(chance.state, chance.natural({ max: 10 })) | ||
while (generator.shrink) { | ||
generator = generator.shrink(generator()) | ||
} | ||
expect(generator, 'when called', 'to be empty') | ||
}) | ||
}) | ||
}) | ||
@@ -304,0 +316,0 @@ |
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
37474
760
10