Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chance-generators

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chance-generators - npm Package Compare versions

Comparing version 1.10.0 to 1.11.0

27

lib/chance-generators.js

@@ -111,3 +111,3 @@ /*global define*/

if (value < 0) {
if (value < 0 && value < (currentLimits.max || 0)) {
var max = currentLimits.max || 0

@@ -118,3 +118,3 @@ limits = {

}
} else if (value > 0) {
} else if (value > 0 && value > (currentLimits.min || 0)) {
var min = currentLimits.min || 0

@@ -145,3 +145,8 @@ limits = {

return createGenerator('pickset', [data, count])
var dataGenerator = generator.args[0]
if (dataGenerator.shrink) {
return createGenerator('pickset', [data.map(dataGenerator.shrink), count])
} else {
return createGenerator('pickset', [data, count])
}
},

@@ -166,2 +171,4 @@ pick: function (generator, data) {

count = count.shrink(data.length)
} else {
return that.identity(data)
}

@@ -183,5 +190,7 @@

var shapeGenerators = generator.args[0]
var shrunk = false;
var newShape = Object.keys(shapeGenerators).reduce(function (result, key) {
var entry = shapeGenerators[key]
if (entry && typeof entry.shrink === 'function') {
shrunk = true
result[key] = entry.shrink(data[key])

@@ -195,9 +204,9 @@ } else {

return createGenerator('shape', [newShape])
if (shrunk) {
return createGenerator('shape', [newShape])
} else {
return that.identity(data)
}
},
string: function (generator, data) {
if (data.length === 0) {
return that.identity(data)
}
var currentLimits = generator.args[0] || {}

@@ -209,2 +218,4 @@ var limits = copy(currentLimits)

limits.length = limits.length.shrink(data.length)
} else {
return that.identity(data)
}

@@ -211,0 +222,0 @@

{
"name": "chance-generators",
"version": "1.10.0",
"version": "1.11.0",
"description": "Random generators based on changejs",

@@ -5,0 +5,0 @@ "main": "lib/chance-generators.js",

@@ -151,8 +151,6 @@ /*global describe, it*/

var generator = chance.n(chance.string, chance.integer({ min: 2, max: 4 }))
for (var i = 0; i < 3; i += 1) {
var generatedValue = generator()
generator = generator.shrink(generatedValue)
expect(generator, 'when called', 'to have items satisfying',
'to be contained by', generatedValue)
while (generator.shrink) {
generator = generator.shrink(generator())
}
expect(generator, 'when called', 'to have length', 2)
})

@@ -340,3 +338,3 @@ })

for (var i = 0; i < 10; i += 1) {
while (generator.shrink) {
generator = generator.shrink(generator())

@@ -343,0 +341,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc