Socket
Socket
Sign inDemoInstall

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.3.0 to 0.3.1

test/test.web.js

119

chance.js

@@ -1,2 +0,2 @@

// Chance.js 0.3.0
// Chance.js 0.3.1
// http://chancejs.com

@@ -47,4 +47,4 @@ // (c) 2013 Victor Quinn

options = options || {};
options.min = options.min || -9007199254740992;
options.max = options.max || 9007199254740992;
options.min = (typeof options.min !== "undefined") ? options.min : -9007199254740992;
options.max = (typeof options.max !== "undefined") ? options.max : 9007199254740992;

@@ -128,40 +128,2 @@ // Greatest of absolute value of either max or min so we know we're

Chance.prototype.name_prefixes = function () {
return [
{name: 'Doctor', abbreviation: 'Dr.'},
{name: 'Miss', abbreviation: 'Miss'},
{name: 'Misses', abbreviation: 'Mrs.'},
{name: 'Mister', abbreviation: 'Mr.'}
];
};
Chance.prototype.name_prefix = function (options) {
options = options || {};
return options.full ?
this.pick(this.name_prefixes()).name :
this.pick(this.name_prefixes()).abbreviation;
};
Chance.prototype.name = function (options) {
options = options || {};
var first = this.capitalize(this.word()),
last = this.capitalize(this.word()),
name;
if (options.middle) {
name = first + ' ' + this.capitalize(this.word()) + ' ' + last;
} else if (options.middle_initial) {
name = first + ' ' + this.character({alpha: true, casing: 'upper'}) + '. ' + last;
} else {
name = first + ' ' + last;
}
if (options.prefix) {
name = this.prefix() + ' ' + name;
}
return name;
};
Chance.prototype.paragraph = function (options) {

@@ -257,2 +219,75 @@ options = options || {};

// -- Name --
Chance.prototype.name = function (options) {
options = options || {};
var first = this.capitalize(this.word()),
last = this.capitalize(this.word()),
name;
if (options.middle) {
name = first + ' ' + this.capitalize(this.word()) + ' ' + last;
} else if (options.middle_initial) {
name = first + ' ' + this.character({alpha: true, casing: 'upper'}) + '. ' + last;
} else {
name = first + ' ' + last;
}
if (options.prefix) {
name = this.prefix() + ' ' + name;
}
return name;
};
Chance.prototype.name_prefixes = function () {
return [
{name: 'Doctor', abbreviation: 'Dr.'},
{name: 'Miss', abbreviation: 'Miss'},
{name: 'Misses', abbreviation: 'Mrs.'},
{name: 'Mister', abbreviation: 'Mr.'}
];
};
Chance.prototype.name_prefix = function (options) {
options = options || {};
return options.full ?
this.pick(this.name_prefixes()).name :
this.pick(this.name_prefixes()).abbreviation;
};
// -- End Name --
// -- Web --
Chance.prototype.domain = function (options) {
options = options || {};
return this.word() + '.' + (options.tld || this.tld());
};
Chance.prototype.email = function (options) {
options = options || {};
return this.word() + '@' + (options.domain || this.domain());
};
Chance.prototype.ip = function () {
// Todo: This could return some reserved IPs. See http://vq.io/137dgYy
// this should probably be updated to account for that rare as it may be
return this.natural({max: 255}) + '.' +
this.natural({max: 255}) + '.' +
this.natural({max: 255}) + '.' +
this.natural({max: 255});
};
Chance.prototype.tlds = function () {
return ['com', 'org', 'edu', 'gov', 'co.uk', 'net', 'io'];
};
Chance.prototype.tld = function () {
return this.pick(this.tlds());
};
// -- End Web --
// -- Address --

@@ -458,3 +493,3 @@

Chance.prototype.VERSION = "0.3.0";
Chance.prototype.VERSION = "0.3.1";

@@ -461,0 +496,0 @@ // Mersenne Twister from https://gist.github.com/banksean/300494

{
"name": "chance",
"version": "0.3.0",
"version": "0.3.1",
"description": "Chance - Utility library to generate anything random",

@@ -5,0 +5,0 @@ "homepage": "http://chancejs.com",

@@ -27,3 +27,3 @@ require.config({

var assert = chai.assert;
require(['test.basic', 'test.text', 'test.address', 'test.misc', 'test.name', 'test.helpers'], function () {
require(['test.basic', 'test.text', 'test.address', 'test.misc', 'test.web', 'test.name', 'test.helpers'], function () {
mocha.reporter('html');

@@ -30,0 +30,0 @@

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

it("can take a zero min and obey it", function () {
_(1000).times(function () {
integer = chance.integer({min: 0});
expect(integer).to.be.above(0);
});
});
it("can take a negative min and obey it", function () {

@@ -54,0 +61,0 @@ _(1000).times(function () {

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