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

chance

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chance - npm Package Compare versions

Comparing version 0.5.6 to 0.5.7

2

bower.json
{
"name": "chance",
"version": "0.5.5",
"version": "0.5.7",
"main": "chance.js",

@@ -5,0 +5,0 @@ "ignore": ["node_modules"],

@@ -5,3 +5,3 @@ {

"description": "Minimalist generator of random strings, numbers, etc.",
"version": "0.5.5",
"version": "0.5.7",
"keywords": ["chance", "random", "generator", "test"],

@@ -8,0 +8,0 @@ "main": "chance.js",

@@ -7,3 +7,2 @@ module.exports = function (grunt) {

options: {
es5: true,
curly: true,

@@ -19,6 +18,6 @@ eqeqeq: true,

trailing: true,
// undef: true,
boss: true,
eqnull: true,
browser: true
browser: true,
white: false
},

@@ -31,10 +30,4 @@ globals: {

},
shell: {
'mocha-phantomjs': {
command: './node_modules/mocha-phantomjs/bin/mocha-phantomjs test/runner.html',
options: {
stdout: true,
stderr: true
}
}
mocha_phantomjs: {
all: ["test/runner.html"]
},

@@ -51,3 +44,3 @@ uglify: {

files: js_files,
tasks: ['jshint', 'shell:mocha-phantomjs', 'uglify']
tasks: ['jshint', 'mocha_phantomjs', 'uglify']
}

@@ -60,6 +53,6 @@ });

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-mocha-phantomjs');
grunt.registerTask('default', ['watch']);
grunt.registerTask('test', ['shell:mocha-phantomjs']);
grunt.registerTask('test', ['mocha_phantomjs']);
};
{
"name": "chance",
"main": "./chance.js",
"version": "0.5.6",
"version": "0.5.7",
"description": "Chance - Utility library to generate anything random",

@@ -22,9 +22,9 @@ "homepage": "http://chancejs.com",

"devDependencies": {
"grunt": "0.4.1",
"grunt-contrib-jshint": "~0.1.1",
"grunt-mocha-phantomjs": "0.3.0",
"grunt-contrib-uglify": "0.2.4",
"grunt-contrib-watch": "0.5.3",
"grunt-shell": "0.3.1",
"mocha-phantomjs": "3.3.2",
"grunt": "0.4.5",
"grunt-contrib-jshint": "0.10.0",
"grunt-mocha-phantomjs": "0.5.0",
"grunt-contrib-uglify": "0.5.0",
"grunt-contrib-watch": "0.6.1",
"grunt-shell": "0.7.0",
"mocha-phantomjs": "3.5.0",
"uglify-js": "1.2.6",

@@ -31,0 +31,0 @@ "grunt-bump": "0.0.11"

@@ -108,27 +108,35 @@ # Chance

```
project : chancejs
repo age : 9 months
active : 48 days
commits : 251
files : 25
project : chancejs
repo age : 1 year
active : 77 days
commits : 302
files : 21
authors :
197 Victor Quinn 78.5%
11 Tim Petricola 4.4%
11 davmillar 4.4%
5 Matt Klaber 2.0%
5 Michael Cordingley 2.0%
4 Kevin Garnett 1.6%
3 qjcg 1.2%
2 Andreas Koeberle 0.8%
2 dhilipsiva 0.8%
2 path411 0.8%
1 Ng, Patrick 0.4%
1 Bitdeli Chef 0.4%
1 Dominic Barnes 0.4%
1 Doug Lawrence 0.4%
1 Johannes Stein 0.4%
1 Adam Krebs 0.4%
1 Richard Anaya 0.4%
1 Ryan Tenney 0.4%
1 leesei 0.4%
226 Victor Quinn 74.8%
13 Tim Petricola 4.3%
11 davmillar 3.6%
5 Michael Cordingley 1.7%
5 Alex DiLiberto 1.7%
5 Matt Klaber 1.7%
4 Kevin Garnett 1.3%
3 Alexandr Lozovyuk 1.0%
3 qjcg 1.0%
2 xshyamx 0.7%
2 Andreas Koeberle 0.7%
2 Iskren Chernev 0.7%
2 Nicholas Johnson 0.7%
2 Pascal Borreli 0.7%
2 dhilipsiva 0.7%
2 path411 0.7%
2 shyam 0.7%
2 Adam Krebs 0.7%
1 Ng, Patrick 0.3%
1 Doug Lawrence 0.3%
1 Dominic Barnes 0.3%
1 leesei 0.3%
1 lkptrzk 0.3%
1 Richard Anaya 0.3%
1 Ryan Tenney 0.3%
1 Samuel Greene 0.3%
1 Johannes Stein 0.3%
```

@@ -138,4 +146,5 @@

[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/victorquinn/chancejs/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
Proudly written in Washington, D.C.

@@ -78,2 +78,18 @@ define(['Chance', 'mocha', 'chai', 'underscore'], function (Chance, mocha, chai, _) {

});
it("states() returns all 50 US States and DC", function () {
expect(chance.states()).to.have.length(51);
});
it("states({territories: true}) returns 50 US States, DC, and 7 US Territories", function () {
expect(chance.states({territories: true})).to.have.length(58);
});
it("states({armed_forces: true}) returns 50 US States, DC, and 3 Armed Forces Military States", function () {
expect(chance.states({armed_forces: true})).to.have.length(54);
});
it("states({territories: true, armed_forces: true}) returns 50 US States, DC, 7 US Territories, and 3 Armed Forces Military States", function () {
expect(chance.states({territories: true, armed_forces: true})).to.have.length(61);
});
});

@@ -80,0 +96,0 @@

@@ -54,4 +54,60 @@ define(['Chance', 'mocha', 'chai', 'underscore'], function (Chance, mocha, chai, _) {

});
it("returns a well shuffled array", function () {
// See http://vq.io/1lEhbim checking it isn't doing that!
arr = ['a', 'b', 'c', 'd', 'e'];
var positions = {
a: [0, 0, 0, 0, 0],
b: [0, 0, 0, 0, 0],
c: [0, 0, 0, 0, 0],
d: [0, 0, 0, 0, 0],
e: [0, 0, 0, 0, 0]
};
_(10000).times(function () {
arr = chance.shuffle(arr);
// Accumulate the position of the a each time
arr.forEach(function(item, index) {
positions[item][index]++;
});
});
// Divide by the estimated number of a's which should appear in each
// position
_.forEach(positions, function(position, index) {
positions[index] = _.map(position, function(item) {
return item/10000;
});
});
_.forEach(positions, function(position, index) {
_.forEach(position, function(item) {
// This should be around 20% give or take a bit since there are
// 5 elements and they should be evenly distributed
expect(item).to.be.within(0.18, 0.22);
});
});
});
});
describe("unique", function () {
it("gives a unique array of the selected function", function () {
_(1000).times(function () {
var arr = chance.unique(chance.email, 25, {domain: "example.com"});
expect(arr).to.be.an('array');
expect(arr[0]).to.match(/example\.com$/);
expect(_.uniq(arr).length).to.equal(25);
});
});
it("throws a RangeError when num is likely out of range", function () {
_(1000).times(function () {
expect(function () {
chance.unique(chance.character, 10, {pool: 'abcde'});
}).to.throw(RangeError, /too large/);
});
});
});
describe("pad()", function () {

@@ -58,0 +114,0 @@ it("always returns same number when width same as the length of the number", function () {

@@ -129,2 +129,12 @@ define(['Chance', 'mocha', 'chai', 'underscore'], function (Chance, mocha, chai, _) {

it("returns a correctly gendered prefix", function () {
_(1000).times(function () {
prefix = chance.name_prefix({ gender: "female" });
expect(prefix).to.not.equal("Mr.");
prefix = chance.name_prefix({ gender: "male" });
expect(prefix).to.not.equal("Mrs.");
expect(prefix).to.not.equal("Miss");
});
});
it("can get full prefix", function () {

@@ -138,3 +148,14 @@ _(1000).times(function () {

});
describe("ssn()", function () {
it("returns a random socal security number", function () {
_(1000).times(function () {
ssn = chance.ssn();
expect(ssn).to.be.a('string');
expect(ssn).to.match(/^\d{3}-\d{2}-\d{4}$/m);
expect(ssn).to.have.length(11);
});
});
});
});
});

Sorry, the diff of this file is too big to display

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