Comparing version 0.1.0 to 0.1.1
121
chance.js
@@ -62,2 +62,122 @@ // Chance.js 0.1 | ||
// Address | ||
// Note: only returning US zip codes, internationalization will be a whole | ||
// other beast to tackle at some point. | ||
Chance.prototype.zip = function (options) { | ||
var zip = ""; | ||
for (var i = 0; i < 5; i++) { | ||
zip += this.natural({min: 0, max: 9}).toString(); | ||
} | ||
if (options && options.plusfour === true) { | ||
zip += '-'; | ||
for (i = 0; i < 4; i++) { | ||
zip += this.natural({min: 0, max: 9}).toString(); | ||
} | ||
} | ||
return zip; | ||
}; | ||
// Street Suffix | ||
Chance.prototype.street_suffixes = function (options) { | ||
var suffixes = []; | ||
if (options && options.full) { | ||
suffixes = ['Avenue', 'Boulevard', 'Center', 'Circle', 'Court', 'Drive', | ||
'Extension', 'Glen', 'Grove', 'Heights', 'Highway', 'Junction', | ||
'Key', 'Lane', 'Loop', 'Manor', 'Mill', 'Park', 'Parkway', 'Pass', | ||
'Path', 'Pike', 'Place', 'Plaza', 'Point', 'Ridge', 'River', 'Road', | ||
'Square', 'Street', 'Terrace', 'Trail', 'Turnpike', 'View', 'Way']; | ||
} else { | ||
suffixes = ['Ave', 'Blvd', 'Ctr', 'Cir', 'Ct', 'Dr', 'Ext', 'Gln', 'Grv', | ||
'Hts', 'Hwy', 'Jct', 'Key', 'Ln', 'Loop', 'Mnr', 'Mill', 'Park', | ||
'Pkwy', 'Pass', 'Path', 'Pike', 'Pl', 'Plz', 'Pt', 'Rdg', 'Riv', | ||
'Rd', 'Sq', 'St', 'Ter', 'Trl', 'Tpke', 'Vw', 'Way']; | ||
} | ||
return suffixes; | ||
}; | ||
Chance.prototype.street_suffix = function (options) { | ||
// These are the most common suffixes. | ||
var suffixes = this.street_suffixes(options), | ||
suffix = suffixes[this.natural({max: suffixes.length - 1})]; | ||
return suffix; | ||
}; | ||
Chance.prototype.states = function () { | ||
return [ | ||
{ name: "Alabama", abbreviation: "AL" }, | ||
{ name: "Alaska", abbreviation: "AK" }, | ||
{ name: "American Samoa", abbreviation: "AS" }, | ||
{ name: "Arizona", abbreviation: "AZ" }, | ||
{ name: "Arkansas", abbreviation: "AR" }, | ||
{ name: "Armed Forces Europe", abbreviation: "AE" }, | ||
{ name: "Armed Forces Pacific", abbreviation: "AP" }, | ||
{ name: "Armed Forces the Americas", abbreviation: "AA" }, | ||
{ name: "California", abbreviation: "CA" }, | ||
{ name: "Colorado", abbreviation: "CO" }, | ||
{ name: "Connecticut", abbreviation: "CT" }, | ||
{ name: "Delaware", abbreviation: "DE" }, | ||
{ name: "District of Columbia", abbreviation: "DC" }, | ||
{ name: "Federated States of Micronesia", abbreviation: "FM" }, | ||
{ name: "Florida", abbreviation: "FL" }, | ||
{ name: "Georgia", abbreviation: "GA" }, | ||
{ name: "Guam", abbreviation: "GU" }, | ||
{ name: "Hawaii", abbreviation: "HI" }, | ||
{ name: "Idaho", abbreviation: "ID" }, | ||
{ name: "Illinois", abbreviation: "IL" }, | ||
{ name: "Indiana", abbreviation: "IN" }, | ||
{ name: "Iowa", abbreviation: "IA" }, | ||
{ name: "Kansas", abbreviation: "KS" }, | ||
{ name: "Kentucky", abbreviation: "KY" }, | ||
{ name: "Louisiana", abbreviation: "LA" }, | ||
{ name: "Maine", abbreviation: "ME" }, | ||
{ name: "Marshall Islands", abbreviation: "MH" }, | ||
{ name: "Maryland", abbreviation: "MD" }, | ||
{ name: "Massachusetts", abbreviation: "MA" }, | ||
{ name: "Michigan", abbreviation: "MI" }, | ||
{ name: "Minnesota", abbreviation: "MN" }, | ||
{ name: "Mississippi", abbreviation: "MS" }, | ||
{ name: "Missouri", abbreviation: "MO" }, | ||
{ name: "Montana", abbreviation: "MT" }, | ||
{ name: "Nebraska", abbreviation: "NE" }, | ||
{ name: "Nevada", abbreviation: "NV" }, | ||
{ name: "New Hampshire", abbreviation: "NH" }, | ||
{ name: "New Jersey", abbreviation: "NJ" }, | ||
{ name: "New Mexico", abbreviation: "NM" }, | ||
{ name: "New York", abbreviation: "NY" }, | ||
{ name: "North Carolina", abbreviation: "NC" }, | ||
{ name: "North Dakota", abbreviation: "ND" }, | ||
{ name: "Northern Mariana Islands", abbreviation: "MP" }, | ||
{ name: "Ohio", abbreviation: "OH" }, | ||
{ name: "Oklahoma", abbreviation: "OK" }, | ||
{ name: "Oregon", abbreviation: "OR" }, | ||
{ name: "Pennsylvania", abbreviation: "PA" }, | ||
{ name: "Puerto Rico", abbreviation: "PR" }, | ||
{ name: "Rhode Island", abbreviation: "RI" }, | ||
{ name: "South Carolina", abbreviation: "SC" }, | ||
{ name: "South Dakota", abbreviation: "SD" }, | ||
{ name: "Tennessee", abbreviation: "TN" }, | ||
{ name: "Texas", abbreviation: "TX" }, | ||
{ name: "Utah", abbreviation: "UT" }, | ||
{ name: "Vermont", abbreviation: "VT" }, | ||
{ name: "Virgin Islands, U.S.", abbreviation: "VI" }, | ||
{ name: "Virginia", abbreviation: "VA" }, | ||
{ name: "Washington", abbreviation: "WA" }, | ||
{ name: "West Virginia", abbreviation: "WV" }, | ||
{ name: "Wisconsin", abbreviation: "WI" }, | ||
{ name: "Wyoming", abbreviation: "WY" } | ||
]; | ||
}; | ||
Chance.prototype.state = function (options) { | ||
var states = this.states(), | ||
state = (options && options.full) ? | ||
states[this.natural({max: states.length - 1})].name : | ||
states[this.natural({max: states.length - 1})].abbreviation; | ||
return state; | ||
}; | ||
// Dice - For all the board game geeks out there, myself included ;) | ||
@@ -72,3 +192,2 @@ Chance.prototype.d4 = function () { return this.natural({min: 1, max: 4}); }; | ||
Chance.prototype.str = function (length) { | ||
@@ -75,0 +194,0 @@ var text = ""; |
@@ -7,2 +7,3 @@ module.exports = function (grunt) { | ||
options: { | ||
es5: true, | ||
curly: true, | ||
@@ -9,0 +10,0 @@ eqeqeq: true, |
{ | ||
"name": "chance", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "ChanceJS - Random generator helper for JavaScript", | ||
"homepage": "http://chancejs.com", | ||
"author": { | ||
"name": "Victor Quinn", | ||
"email": "mail@victorquinn.com", | ||
"url": "http://victorquinn.com" | ||
}, | ||
"author": "Victor Quinn <mail@victorquinn.com>", | ||
"bugs": { | ||
@@ -11,0 +8,0 @@ "url": "https://github.com/victorquinn/chancejs/issues" |
@@ -1,4 +0,6 @@ | ||
chancejs | ||
ChanceJS | ||
======== | ||
ChanceJS - Random generator helper for JavaScript | ||
Homepage: [http://chancejs.com](http://chancejs.com) |
@@ -30,3 +30,3 @@ require.config({ | ||
var assert = chai.assert; | ||
require(['test.basic.js', 'test.misc.js'], function () { | ||
require(['test.basic.js', 'test.misc.js', 'test.address.js'], function () { | ||
mocha.reporter('html'); | ||
@@ -33,0 +33,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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
28380
10
636
7