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

chance-generators

Package Overview
Dependencies
Maintainers
2
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 2.1.0 to 2.1.1

2

lib/chance-generators.js

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

} else {
return generator
return mapGenerator
}

@@ -92,0 +92,0 @@ }

{
"name": "chance-generators",
"version": "2.1.0",
"version": "2.1.1",
"description": "Random generators based on changejs",

@@ -27,3 +27,3 @@ "main": "lib/chance-generators.js",

"standard": "5.4.1",
"unexpected": "10.5.1",
"unexpected": "10.33.2",
"unexpected-documentation-site-generator": "4.2.0",

@@ -30,0 +30,0 @@ "unexpected-markdown": "1.6.1"

@@ -78,2 +78,10 @@ /*global describe, it*/

})
it('keeps the map even when called out of order', () => {
let generator = chance.integer({ min: -10, max: 10 }).map(v => '' + v)
const val = generator()
generator()
generator = generator.shrink(val)
expect(generator, 'when called', 'to be a string')
})
})

@@ -255,2 +263,32 @@ })

describe('pickone', () => {
describe('given an array', () => {
it('returns a new generator picking a random element from the array', () => {
const arr = [42, 'foo', { wat: 'taw' }]
expect(chance.pickone(arr), 'when called', 'to be one of', arr)
})
})
describe('given an array of generators', () => {
it('returns a new generator picking a random elements from the array ' +
'where the items are generated by the generators in the array', () => {
const coordinates = chance.shape({
x: chance.integer,
y: chance.integer
})
for (var i = 0; i < 10; i += 1) {
expect(
chance.pickone([chance.integer, coordinates, chance.string, true]),
'when called',
expect.it('to be a number').or('to be a string').or('to be a boolean').or('to satisfy', {
x: expect.it('to be a number'),
y: expect.it('to be a number')
})
)
}
})
})
})
describe('unique', () => {

@@ -257,0 +295,0 @@ describe('given a generator and a number', () => {

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