From 7dfc90c0d65cf2e95b4001e15e72dcc99b2a0701 Mon Sep 17 00:00:00 2001 From: Bruno Trecenti Date: Wed, 20 May 2015 16:39:04 -0300 Subject: [PATCH] moved to npm instead of gulp --- examples/chance.js | 1077 ++++++++++---------------------- examples/tech-radar.js | 440 ------------- examples/tech-radar.min.js | 7 +- examples/tech-radar.min.js.map | 6 +- gulpfile.js | 98 --- karma-dist.conf.js | 24 + karma.conf.js | 23 +- package.json | 29 +- scripts/publish-examples.js | 15 + 9 files changed, 402 insertions(+), 1317 deletions(-) delete mode 100644 examples/tech-radar.js delete mode 100644 gulpfile.js create mode 100644 karma-dist.conf.js create mode 100644 scripts/publish-examples.js diff --git a/examples/chance.js b/examples/chance.js index 068bc74..e8af4c4 100644 --- a/examples/chance.js +++ b/examples/chance.js @@ -1,4 +1,4 @@ -// Chance.js 0.6.1 +// Chance.js 0.5.5 // http://chancejs.com // (c) 2013 Victor Quinn // Chance may be freely distributed or modified under the MIT license. @@ -13,11 +13,8 @@ var CHARS_UPPER = CHARS_LOWER.toUpperCase(); var HEX_POOL = NUMBERS + "abcdef"; - // Cached array helpers - var slice = Array.prototype.slice; - // Constructor - function Chance (seed) { + var Chance = function (seed) { if (!(this instanceof Chance)) { return new Chance(seed); } @@ -38,24 +35,19 @@ return this.mt.random(this.seed); }; } - - return this; - } - - Chance.prototype.VERSION = "0.6.1"; + }; // Random helper functions function initOptions(options, defaults) { options || (options = {}); - - if (defaults) { - for (var i in defaults) { - if (typeof options[i] === 'undefined') { - options[i] = defaults[i]; - } + if (!defaults) { + return options; + } + for (var i in defaults) { + if (typeof options[i] === 'undefined') { + options[i] = defaults[i]; } } - return options; } @@ -120,7 +112,7 @@ // the trailing zeroes are dropped. Left to the consumer if trailing zeroes are // needed Chance.prototype.floating = function (options) { - var num; + var num, range; options = initOptions(options, {fixed : 4}); var fixed = Math.pow(10, options.fixed); @@ -175,14 +167,40 @@ return this.integer(options); }; + Chance.prototype.normal = function (options) { + options = initOptions(options, {mean : 0, dev : 1}); + + // The Marsaglia Polar method + var s, u, v, norm, + mean = options.mean, + dev = options.dev; + + do { + // U and V are from the uniform distribution on (-1, 1) + u = this.random() * 2 - 1; + v = this.random() * 2 - 1; + + s = u * u + v * v; + } while (s >= 1); + + // Compute the standard normal variate + norm = u * Math.sqrt(-2 * Math.log(s) / s); + + // Shape and scale + return dev * norm + mean; + }; + Chance.prototype.string = function (options) { options = initOptions(options); var length = options.length || this.natural({min: 5, max: 20}), - pool = options.pool, - text = this.n(this.character, length, {pool: pool}); + text = '', + pool = options.pool; - return text.join(""); + for (var i = 0; i < length; i++) { + text += this.character({pool: pool}); + } + return text; }; // -- End Basics -- @@ -194,57 +212,13 @@ }; Chance.prototype.mixin = function (obj) { + var chance = this; for (var func_name in obj) { Chance.prototype[func_name] = obj[func_name]; } return this; }; - // Given a function that generates something random and a number of items to generate, - // return an array of items where none repeat. - Chance.prototype.unique = function(fn, num, options) { - options = initOptions(options, { - // Default comparator to check that val is not already in arr. - // Should return `false` if item not in array, `true` otherwise - comparator: function(arr, val) { - return arr.indexOf(val) !== -1; - } - }); - - var arr = [], count = 0, result, MAX_DUPLICATES = num * 50, params = slice.call(arguments, 2); - - while (arr.length < num) { - result = fn.apply(this, params); - if (!options.comparator(arr, result)) { - arr.push(result); - // reset count when unique found - count = 0; - } - - if (++count > MAX_DUPLICATES) { - throw new RangeError("Chance: num is likely too large for sample set"); - } - } - return arr; - }; - - /** - * Gives an array of n random terms - * @param fn the function that generates something random - * @param n number of terms to generate - * @param options options for the function fn. - * There can be more parameters after these. All additional parameters are provided to the given function - */ - Chance.prototype.n = function(fn, n, options) { - var i = n || 1, arr = [], params = slice.call(arguments, 2); - - for (null; i--; null) { - arr.push(fn.apply(this, params)); - } - - return arr; - }; - // H/T to SO for this one: http://vq.io/OtUrZ5 Chance.prototype.pad = function (number, width, pad) { // Default pad to 0 if none provided @@ -280,48 +254,6 @@ return new_array; }; - // Returns a single item from an array with relative weighting of odds - Chance.prototype.weighted = function(arr, weights) { - if (arr.length !== weights.length) { - throw new RangeError("Chance: length of array and weights must match"); - } - - // If any of the weights are less than 1, we want to scale them up to whole - // numbers for the rest of this logic to work - if (weights.some(function(weight) { return weight < 1; })) { - var min = weights.reduce(function(min, weight) { - return (weight < min) ? weight : min; - }, weights[0]); - - var scaling_factor = 1 / min; - - weights = weights.map(function(weight) { - return weight * scaling_factor; - }); - } - - var sum = weights.reduce(function(total, weight) { - return total + weight; - }, 0); - - // get an index - var selected = this.natural({ min: 1, max: sum }); - - var total = 0; - var chosen; - // Using some() here so we can bail as soon as we get our match - weights.some(function(weight, index) { - if (selected <= total + weight) { - chosen = arr[index]; - return true; - } - total += weight; - return false; - }); - - return chosen; - }; - // -- End Helpers -- // -- Text -- @@ -330,7 +262,11 @@ options = initOptions(options); var sentences = options.sentences || this.natural({min: 3, max: 7}), - sentence_array = this.n(this.sentence, sentences); + sentence_array = []; + + for (var i = 0; i < sentences; i++) { + sentence_array.push(this.sentence()); + } return sentence_array.join(' '); }; @@ -341,7 +277,11 @@ options = initOptions(options); var words = options.words || this.natural({min: 12, max: 18}), - text, word_array = this.n(this.word, words); + text, word_array = []; + + for (var i = 0; i < words; i++) { + word_array.push(this.word()); + } text = word_array.join(' '); @@ -413,30 +353,27 @@ Chance.prototype.age = function (options) { options = initOptions(options); - var ageRange; + var age; switch (options.type) { - case 'child': - ageRange = {min: 1, max: 12}; - break; - case 'teen': - ageRange = {min: 13, max: 19}; - break; - case 'adult': - ageRange = {min: 18, max: 65}; - break; - case 'senior': - ageRange = {min: 65, max: 100}; - break; - case 'all': - ageRange = {min: 1, max: 100}; - break; - default: - ageRange = {min: 18, max: 65}; - break; + case 'child': + age = this.natural({min: 1, max: 12}); + break; + case 'teen': + age = this.natural({min: 13, max: 19}); + break; + case 'adult': + age = this.natural({min: 18, max: 120}); + break; + case 'senior': + age = this.natural({min: 65, max: 120}); + break; + default: + age = this.natural({min: 1, max: 120}); + break; } - return this.natural(ageRange); + return age; }; Chance.prototype.birthday = function (options) { @@ -447,33 +384,24 @@ return this.date(options); }; - // CPF; ID to identify taxpayers in Brazil - Chance.prototype.cpf = function () { - var n = this.n(this.natural, 9, { max: 9 }); - var d1 = n[8]*2+n[7]*3+n[6]*4+n[5]*5+n[4]*6+n[3]*7+n[2]*8+n[1]*9+n[0]*10; - d1 = 11 - (d1 % 11); - if (d1>=10) { - d1 = 0; - } - var d2 = d1*2+n[8]*3+n[7]*4+n[6]*5+n[5]*6+n[4]*7+n[3]*8+n[2]*9+n[1]*10+n[0]*11; - d2 = 11 - (d2 % 11); - if (d2>=10) { - d2 = 0; - } - return ''+n[0]+n[1]+n[2]+'.'+n[3]+n[4]+n[5]+'.'+n[6]+n[7]+n[8]+'-'+d1+d2; + var firstNames = { + "male": ["James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Charles", "Thomas", "Christopher", "Daniel", "Matthew", "George", "Donald", "Anthony", "Paul", "Mark", "Edward", "Steven", "Kenneth", "Andrew", "Brian", "Joshua", "Kevin", "Ronald", "Timothy", "Jason", "Jeffrey", "Frank", "Gary", "Ryan", "Nicholas", "Eric", "Stephen", "Jacob", "Larry", "Jonathan", "Scott", "Raymond", "Justin", "Brandon", "Gregory", "Samuel", "Benjamin", "Patrick", "Jack", "Henry", "Walter", "Dennis", "Jerry", "Alexander", "Peter", "Tyler", "Douglas", "Harold", "Aaron", "Jose", "Adam", "Arthur", "Zachary", "Carl", "Nathan", "Albert", "Kyle", "Lawrence", "Joe", "Willie", "Gerald", "Roger", "Keith", "Jeremy", "Terry", "Harry", "Ralph", "Sean", "Jesse", "Roy", "Louis", "Billy", "Austin", "Bruce", "Eugene", "Christian", "Bryan", "Wayne", "Russell", "Howard", "Fred", "Ethan", "Jordan", "Philip", "Alan", "Juan", "Randy", "Vincent", "Bobby", "Dylan", "Johnny", "Phillip", "Victor", "Clarence", "Ernest", "Martin", "Craig", "Stanley", "Shawn", "Travis", "Bradley", "Leonard", "Earl", "Gabriel", "Jimmy", "Francis", "Todd", "Noah", "Danny", "Dale", "Cody", "Carlos", "Allen", "Frederick", "Logan", "Curtis", "Alex", "Joel", "Luis", "Norman", "Marvin", "Glenn", "Tony", "Nathaniel", "Rodney", "Melvin", "Alfred", "Steve", "Cameron", "Chad", "Edwin", "Caleb", "Evan", "Antonio", "Lee", "Herbert", "Jeffery", "Isaac", "Derek", "Ricky", "Marcus", "Theodore", "Elijah", "Luke", "Jesus", "Eddie", "Troy", "Mike", "Dustin", "Ray", "Adrian", "Bernard", "Leroy", "Angel", "Randall", "Wesley", "Ian", "Jared", "Mason", "Hunter", "Calvin", "Oscar", "Clifford", "Jay", "Shane", "Ronnie", "Barry", "Lucas", "Corey", "Manuel", "Leo", "Tommy", "Warren", "Jackson", "Isaiah", "Connor", "Don", "Dean", "Jon", "Julian", "Miguel", "Bill", "Lloyd", "Charlie", "Mitchell", "Leon", "Jerome", "Darrell", "Jeremiah", "Alvin", "Brett", "Seth", "Floyd", "Jim", "Blake", "Micheal", "Gordon", "Trevor", "Lewis", "Erik", "Edgar", "Vernon", "Devin", "Gavin", "Jayden", "Chris", "Clyde", "Tom", "Derrick", "Mario", "Brent", "Marc", "Herman", "Chase", "Dominic", "Ricardo", "Franklin", "Maurice", "Max", "Aiden", "Owen", "Lester", "Gilbert", "Elmer", "Gene", "Francisco", "Glen", "Cory", "Garrett", "Clayton", "Sam", "Jorge", "Chester", "Alejandro", "Jeff", "Harvey", "Milton", "Cole", "Ivan", "Andre", "Duane", "Landon"], + "female": ["Mary", "Emma", "Elizabeth", "Minnie", "Margaret", "Ida", "Alice", "Bertha", "Sarah", "Annie", "Clara", "Ella", "Florence", "Cora", "Martha", "Laura", "Nellie", "Grace", "Carrie", "Maude", "Mabel", "Bessie", "Jennie", "Gertrude", "Julia", "Hattie", "Edith", "Mattie", "Rose", "Catherine", "Lillian", "Ada", "Lillie", "Helen", "Jessie", "Louise", "Ethel", "Lula", "Myrtle", "Eva", "Frances", "Lena", "Lucy", "Edna", "Maggie", "Pearl", "Daisy", "Fannie", "Josephine", "Dora", "Rosa", "Katherine", "Agnes", "Marie", "Nora", "May", "Mamie", "Blanche", "Stella", "Ellen", "Nancy", "Effie", "Sallie", "Nettie", "Della", "Lizzie", "Flora", "Susie", "Maud", "Mae", "Etta", "Harriet", "Sadie", "Caroline", "Katie", "Lydia", "Elsie", "Kate", "Susan", "Mollie", "Alma", "Addie", "Georgia", "Eliza", "Lulu", "Nannie", "Lottie", "Amanda", "Belle", "Charlotte", "Rebecca", "Ruth", "Viola", "Olive", "Amelia", "Hannah", "Jane", "Virginia", "Emily", "Matilda", "Irene", "Kathryn", "Esther", "Willie", "Henrietta", "Ollie", "Amy", "Rachel", "Sara", "Estella", "Theresa", "Augusta", "Ora", "Pauline", "Josie", "Lola", "Sophia", "Leona", "Anne", "Mildred", "Ann", "Beulah", "Callie", "Lou", "Delia", "Eleanor", "Barbara", "Iva", "Louisa", "Maria", "Mayme", "Evelyn", "Estelle", "Nina", "Betty", "Marion", "Bettie", "Dorothy", "Luella", "Inez", "Lela", "Rosie", "Allie", "Millie", "Janie", "Cornelia", "Victoria", "Ruby", "Winifred", "Alta", "Celia", "Christine", "Beatrice", "Birdie", "Harriett", "Mable", "Myra", "Sophie", "Tillie", "Isabel", "Sylvia", "Carolyn", "Isabelle", "Leila", "Sally", "Ina", "Essie", "Bertie", "Nell", "Alberta", "Katharine", "Lora", "Rena", "Mina", "Rhoda", "Mathilda", "Abbie", "Eula", "Dollie", "Hettie", "Eunice", "Fanny", "Ola", "Lenora", "Adelaide", "Christina", "Lelia", "Nelle", "Sue", "Johanna", "Lilly", "Lucinda", "Minerva", "Lettie", "Roxie", "Cynthia", "Helena", "Hilda", "Hulda", "Bernice", "Genevieve", "Jean", "Cordelia", "Marian", "Francis", "Jeanette", "Adeline", "Gussie", "Leah", "Lois", "Lura", "Mittie", "Hallie", "Isabella", "Olga", "Phoebe", "Teresa", "Hester", "Lida", "Lina", "Winnie", "Claudia", "Marguerite", "Vera", "Cecelia", "Bess", "Emilie", "John", "Rosetta", "Verna", "Myrtie", "Cecilia", "Elva", "Olivia", "Ophelia", "Georgie", "Elnora", "Violet", "Adele", "Lily", "Linnie", "Loretta", "Madge", "Polly", "Virgie", "Eugenia", "Lucile", "Lucille", "Mabelle", "Rosalie"] }; Chance.prototype.first = function (options) { options = initOptions(options, {gender: this.gender()}); - return this.pick(this.get("firstNames")[options.gender.toLowerCase()]); + return this.pick(firstNames[options.gender.toLowerCase()]); }; Chance.prototype.gender = function () { return this.pick(['Male', 'Female']); }; + var lastNames = ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin', 'Thompson', 'Garcia', 'Martinez', 'Robinson', 'Clark', 'Rodriguez', 'Lewis', 'Lee', 'Walker', 'Hall', 'Allen', 'Young', 'Hernandez', 'King', 'Wright', 'Lopez', 'Hill', 'Scott', 'Green', 'Adams', 'Baker', 'Gonzalez', 'Nelson', 'Carter', 'Mitchell', 'Perez', 'Roberts', 'Turner', 'Phillips', 'Campbell', 'Parker', 'Evans', 'Edwards', 'Collins', 'Stewart', 'Sanchez', 'Morris', 'Rogers', 'Reed', 'Cook', 'Morgan', 'Bell', 'Murphy', 'Bailey', 'Rivera', 'Cooper', 'Richardson', 'Cox', 'Howard', 'Ward', 'Torres', 'Peterson', 'Gray', 'Ramirez', 'James', 'Watson', 'Brooks', 'Kelly', 'Sanders', 'Price', 'Bennett', 'Wood', 'Barnes', 'Ross', 'Henderson', 'Coleman', 'Jenkins', 'Perry', 'Powell', 'Long', 'Patterson', 'Hughes', 'Flores', 'Washington', 'Butler', 'Simmons', 'Foster', 'Gonzales', 'Bryant', 'Alexander', 'Russell', 'Griffin', 'Diaz', 'Hayes', 'Myers', 'Ford', 'Hamilton', 'Graham', 'Sullivan', 'Wallace', 'Woods', 'Cole', 'West', 'Jordan', 'Owens', 'Reynolds', 'Fisher', 'Ellis', 'Harrison', 'Gibson', 'McDonald', 'Cruz', 'Marshall', 'Ortiz', 'Gomez', 'Murray', 'Freeman', 'Wells', 'Webb', 'Simpson', 'Stevens', 'Tucker', 'Porter', 'Hunter', 'Hicks', 'Crawford', 'Henry', 'Boyd', 'Mason', 'Morales', 'Kennedy', 'Warren', 'Dixon', 'Ramos', 'Reyes', 'Burns', 'Gordon', 'Shaw', 'Holmes', 'Rice', 'Robertson', 'Hunt', 'Black', 'Daniels', 'Palmer', 'Mills', 'Nichols', 'Grant', 'Knight', 'Ferguson', 'Rose', 'Stone', 'Hawkins', 'Dunn', 'Perkins', 'Hudson', 'Spencer', 'Gardner', 'Stephens', 'Payne', 'Pierce', 'Berry', 'Matthews', 'Arnold', 'Wagner', 'Willis', 'Ray', 'Watkins', 'Olson', 'Carroll', 'Duncan', 'Snyder', 'Hart', 'Cunningham', 'Bradley', 'Lane', 'Andrews', 'Ruiz', 'Harper', 'Fox', 'Riley', 'Armstrong', 'Carpenter', 'Weaver', 'Greene', 'Lawrence', 'Elliott', 'Chavez', 'Sims', 'Austin', 'Peters', 'Kelley', 'Franklin', 'Lawson', 'Fields', 'Gutierrez', 'Ryan', 'Schmidt', 'Carr', 'Vasquez', 'Castillo', 'Wheeler', 'Chapman', 'Oliver', 'Montgomery', 'Richards', 'Williamson', 'Johnston', 'Banks', 'Meyer', 'Bishop', 'McCoy', 'Howell', 'Alvarez', 'Morrison', 'Hansen', 'Fernandez', 'Garza', 'Harvey', 'Little', 'Burton', 'Stanley', 'Nguyen', 'George', 'Jacobs', 'Reid', 'Kim', 'Fuller', 'Lynch', 'Dean', 'Gilbert', 'Garrett', 'Romero', 'Welch', 'Larson', 'Frazier', 'Burke', 'Hanson', 'Day', 'Mendoza', 'Moreno', 'Bowman', 'Medina', 'Fowler', 'Brewer', 'Hoffman', 'Carlson', 'Silva', 'Pearson', 'Holland', 'Douglas', 'Fleming', 'Jensen', 'Vargas', 'Byrd', 'Davidson', 'Hopkins', 'May', 'Terry', 'Herrera', 'Wade', 'Soto', 'Walters', 'Curtis', 'Neal', 'Caldwell', 'Lowe', 'Jennings', 'Barnett', 'Graves', 'Jimenez', 'Horton', 'Shelton', 'Barrett', 'Obrien', 'Castro', 'Sutton', 'Gregory', 'McKinney', 'Lucas', 'Miles', 'Craig', 'Rodriquez', 'Chambers', 'Holt', 'Lambert', 'Fletcher', 'Watts', 'Bates', 'Hale', 'Rhodes', 'Pena', 'Beck', 'Newman', 'Haynes', 'McDaniel', 'Mendez', 'Bush', 'Vaughn', 'Parks', 'Dawson', 'Santiago', 'Norris', 'Hardy', 'Love', 'Steele', 'Curry', 'Powers', 'Schultz', 'Barker', 'Guzman', 'Page', 'Munoz', 'Ball', 'Keller', 'Chandler', 'Weber', 'Leonard', 'Walsh', 'Lyons', 'Ramsey', 'Wolfe', 'Schneider', 'Mullins', 'Benson', 'Sharp', 'Bowen', 'Daniel', 'Barber', 'Cummings', 'Hines', 'Baldwin', 'Griffith', 'Valdez', 'Hubbard', 'Salazar', 'Reeves', 'Warner', 'Stevenson', 'Burgess', 'Santos', 'Tate', 'Cross', 'Garner', 'Mann', 'Mack', 'Moss', 'Thornton', 'Dennis', 'McGee', 'Farmer', 'Delgado', 'Aguilar', 'Vega', 'Glover', 'Manning', 'Cohen', 'Harmon', 'Rodgers', 'Robbins', 'Newton', 'Todd', 'Blair', 'Higgins', 'Ingram', 'Reese', 'Cannon', 'Strickland', 'Townsend', 'Potter', 'Goodwin', 'Walton', 'Rowe', 'Hampton', 'Ortega', 'Patton', 'Swanson', 'Joseph', 'Francis', 'Goodman', 'Maldonado', 'Yates', 'Becker', 'Erickson', 'Hodges', 'Rios', 'Conner', 'Adkins', 'Webster', 'Norman', 'Malone', 'Hammond', 'Flowers', 'Cobb', 'Moody', 'Quinn', 'Blake', 'Maxwell', 'Pope', 'Floyd', 'Osborne', 'Paul', 'McCarthy', 'Guerrero', 'Lindsey', 'Estrada', 'Sandoval', 'Gibbs', 'Tyler', 'Gross', 'Fitzgerald', 'Stokes', 'Doyle', 'Sherman', 'Saunders', 'Wise', 'Colon', 'Gill', 'Alvarado', 'Greer', 'Padilla', 'Simon', 'Waters', 'Nunez', 'Ballard', 'Schwartz', 'McBride', 'Houston', 'Christensen', 'Klein', 'Pratt', 'Briggs', 'Parsons', 'McLaughlin', 'Zimmerman', 'French', 'Buchanan', 'Moran', 'Copeland', 'Roy', 'Pittman', 'Brady', 'McCormick', 'Holloway', 'Brock', 'Poole', 'Frank', 'Logan', 'Owen', 'Bass', 'Marsh', 'Drake', 'Wong', 'Jefferson', 'Park', 'Morton', 'Abbott', 'Sparks', 'Patrick', 'Norton', 'Huff', 'Clayton', 'Massey', 'Lloyd', 'Figueroa', 'Carson', 'Bowers', 'Roberson', 'Barton', 'Tran', 'Lamb', 'Harrington', 'Casey', 'Boone', 'Cortez', 'Clarke', 'Mathis', 'Singleton', 'Wilkins', 'Cain', 'Bryan', 'Underwood', 'Hogan', 'McKenzie', 'Collier', 'Luna', 'Phelps', 'McGuire', 'Allison', 'Bridges', 'Wilkerson', 'Nash', 'Summers', 'Atkins']; + Chance.prototype.last = function () { - return this.pick(this.get("lastNames")); + return this.pick(lastNames); }; Chance.prototype.name = function (options) { @@ -492,30 +420,19 @@ } if (options.prefix) { - name = this.prefix(options) + ' ' + name; + name = this.prefix() + ' ' + name; } return name; }; - // Return the list of available name prefixes based on supplied gender. - Chance.prototype.name_prefixes = function (gender) { - gender = gender || "all"; - - var prefixes = [ - { name: 'Doctor', abbreviation: 'Dr.' } + Chance.prototype.name_prefixes = function () { + return [ + {name: 'Doctor', abbreviation: 'Dr.'}, + {name: 'Miss', abbreviation: 'Miss'}, + {name: 'Misses', abbreviation: 'Mrs.'}, + {name: 'Mister', abbreviation: 'Mr.'} ]; - - if (gender === "male" || gender === "all") { - prefixes.push({ name: 'Mister', abbreviation: 'Mr.' }); - } - - if (gender === "female" || gender === "all") { - prefixes.push({ name: 'Miss', abbreviation: 'Miss' }); - prefixes.push({ name: 'Misses', abbreviation: 'Mrs.' }); - } - - return prefixes; }; // Alias for name_prefix @@ -524,37 +441,16 @@ }; Chance.prototype.name_prefix = function (options) { - options = initOptions(options, { gender: "all" }); + options = initOptions(options); return options.full ? - this.pick(this.name_prefixes(options.gender)).name : - this.pick(this.name_prefixes(options.gender)).abbreviation; - }; - - Chance.prototype.ssn = function (options) { - options = initOptions(options, {ssnFour: false, dashes: true}); - var ssn_pool = "1234567890", - ssn, - dash = options.dashes ? '-' : ''; - - if(!options.ssnFour) { - ssn = this.string({pool: ssn_pool, length: 3}) + dash + - this.string({pool: ssn_pool, length: 2}) + dash + - this.string({pool: ssn_pool, length: 4}); - } else { - ssn = this.string({pool: ssn_pool, length: 4}); - } - return ssn; + this.pick(this.name_prefixes()).name : + this.pick(this.name_prefixes()).abbreviation; }; // -- End Person -- // -- Web -- - // Apple Push Token - Chance.prototype.apple_token = function (options) { - return this.string({ pool: "abcdef1234567890", length: 64 }); - }; - Chance.prototype.color = function (options) { function gray(value, delimiter) { return [value, value, value].join(delimiter || ''); @@ -589,7 +485,7 @@ Chance.prototype.email = function (options) { options = initOptions(options); - return this.word({length: options.length}) + '@' + (options.domain || this.domain()); + return this.word() + '@' + (options.domain || this.domain()); }; Chance.prototype.fbid = function () { @@ -599,7 +495,6 @@ Chance.prototype.google_analytics = function () { var account = this.pad(this.natural({max: 999999}), 6); var property = this.pad(this.natural({max: 99}), 2); - return 'UA-' + account + '-' + property; }; @@ -617,9 +512,12 @@ }; Chance.prototype.ipv6 = function () { - var ip_addr = this.n(this.hash, 8, {length: 4}); + var ip_addr = ""; - return ip_addr.join(":"); + for (var i = 0; i < 8; i++) { + ip_addr += this.hash({length: 4}) + ':'; + } + return ip_addr.substr(0, ip_addr.length - 1); }; Chance.prototype.klout = function () { @@ -640,25 +538,17 @@ // -- End Web -- - // -- Location -- + // -- Address -- Chance.prototype.address = function (options) { options = initOptions(options); return this.natural({min: 5, max: 2000}) + ' ' + this.street(options); }; - Chance.prototype.altitude = function (options) { - options = initOptions(options, {fixed : 5, max: 8848}); - return this.floating({min: 0, max: options.max, fixed: options.fixed}); - }; - Chance.prototype.areacode = function (options) { options = initOptions(options, {parens : true}); // Don't want area codes to start with 1, or have a 9 as the second digit - var areacode = this.natural({min: 2, max: 9}).toString() + - this.natural({min: 0, max: 8}).toString() + - this.natural({min: 0, max: 9}).toString(); - + var areacode = this.natural({min: 2, max: 9}).toString() + this.natural({min: 0, max: 8}).toString() + this.natural({min: 0, max: 9}).toString(); return options.parens ? '(' + areacode + ')' : areacode; }; @@ -671,19 +561,19 @@ return this.latitude(options) + ', ' + this.longitude(options); }; - Chance.prototype.depth = function (options) { - options = initOptions(options, {fixed: 5, min: -2550}); - return this.floating({min: options.min, max: 0, fixed: options.fixed}); + Chance.prototype.geoJson = function (options) { + options = initOptions(options); + return this.latitude(options) + ', ' + this.longitude(options) + ', ' + this.altitude(options); }; - Chance.prototype.geohash = function (options) { - options = initOptions(options, { length: 7 }); - return this.string({ length: options.length, pool: '0123456789bcdefghjkmnpqrstuvwxyz' }); + Chance.prototype.altitude = function (options) { + options = initOptions(options, {fixed : 5}); + return this.floating({min: 0, max: 32736000, fixed: options.fixed}); }; - Chance.prototype.geojson = function (options) { - options = initOptions(options); - return this.latitude(options) + ', ' + this.longitude(options) + ', ' + this.altitude(options); + Chance.prototype.depth = function (options) { + options = initOptions(options, {fixed: 5}); + return this.floating({min: -35994, max: 0, fixed: options.fixed}); }; Chance.prototype.latitude = function (options) { @@ -702,12 +592,8 @@ options.parens = false; } var areacode = this.areacode(options).toString(); - var exchange = this.natural({min: 2, max: 9}).toString() + - this.natural({min: 0, max: 9}).toString() + - this.natural({min: 0, max: 9}).toString(); - + var exchange = this.natural({min: 2, max: 9}).toString() + this.natural({min: 0, max: 9}).toString() + this.natural({min: 0, max: 9}).toString(); var subscriber = this.natural({min: 1000, max: 9999}).toString(); // this could be random [0-9]{4} - return options.formatted ? areacode + ' ' + exchange + '-' + subscriber : areacode + exchange + subscriber; }; @@ -723,7 +609,25 @@ }; Chance.prototype.provinces = function () { - return this.get("provinces"); + return [ + {name: 'Alberta', abbreviation: 'AB'}, + {name: 'British Columbia', abbreviation: 'BC'}, + {name: 'Manitoba', abbreviation: 'MB'}, + {name: 'New Brunswick', abbreviation: 'NB'}, + {name: 'Newfoundland and Labrador', abbreviation: 'NL'}, + {name: 'Nova Scotia', abbreviation: 'NS'}, + {name: 'Ontario', abbreviation: 'ON'}, + {name: 'Prince Edward Island', abbreviation: 'PE'}, + {name: 'Quebec', abbreviation: 'QC'}, + {name: 'Saskatchewan', abbreviation: 'SK'}, + + // The case could be made that the following are not actually provinces + // since they are technically considered "territories" however they all + // look the same on an envelope! + {name: 'Northwest Territories', abbreviation: 'NT'}, + {name: 'Nunavut', abbreviation: 'NU'}, + {name: 'Yukon', abbreviation: 'YT'} + ]; }; Chance.prototype.province = function (options) { @@ -732,30 +636,97 @@ this.pick(this.provinces()).abbreviation; }; + Chance.prototype.radio = function (options) { + // Initial Letter (Typically Designated by Side of Mississippi River) + options = initOptions(options, {side : "?"}); + var fl = ""; + switch (options.side.toLowerCase()) { + case "east": + case "e": + fl = "W"; + break; + case "west": + case "w": + fl = "K"; + break; + default: + fl = this.character({pool: "KW"}); + break; + } + + return fl + this.character({alpha: true, casing: "upper"}) + this.character({alpha: true, casing: "upper"}) + this.character({alpha: true, casing: "upper"}); + }; + Chance.prototype.state = function (options) { return (options && options.full) ? - this.pick(this.states(options)).name : - this.pick(this.states(options)).abbreviation; + this.pick(this.states()).name : + this.pick(this.states()).abbreviation; }; - Chance.prototype.states = function (options) { - options = initOptions(options); - - var states, - us_states_and_dc = this.get("us_states_and_dc"), - territories = this.get("territories"), - armed_forces = this.get("armed_forces"); - - states = us_states_and_dc; - - if (options.territories) { - states = states.concat(territories); - } - if (options.armed_forces) { - states = states.concat(armed_forces); - } - - return states; + 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.street = function (options) { @@ -776,23 +747,69 @@ Chance.prototype.street_suffixes = function () { // These are the most common suffixes. - return this.get("street_suffixes"); + return [ + {name: 'Avenue', abbreviation: 'Ave'}, + {name: 'Boulevard', abbreviation: 'Blvd'}, + {name: 'Center', abbreviation: 'Ctr'}, + {name: 'Circle', abbreviation: 'Cir'}, + {name: 'Court', abbreviation: 'Ct'}, + {name: 'Drive', abbreviation: 'Dr'}, + {name: 'Extension', abbreviation: 'Ext'}, + {name: 'Glen', abbreviation: 'Gln'}, + {name: 'Grove', abbreviation: 'Grv'}, + {name: 'Heights', abbreviation: 'Hts'}, + {name: 'Highway', abbreviation: 'Hwy'}, + {name: 'Junction', abbreviation: 'Jct'}, + {name: 'Key', abbreviation: 'Key'}, + {name: 'Lane', abbreviation: 'Ln'}, + {name: 'Loop', abbreviation: 'Loop'}, + {name: 'Manor', abbreviation: 'Mnr'}, + {name: 'Mill', abbreviation: 'Mill'}, + {name: 'Park', abbreviation: 'Park'}, + {name: 'Parkway', abbreviation: 'Pkwy'}, + {name: 'Pass', abbreviation: 'Pass'}, + {name: 'Path', abbreviation: 'Path'}, + {name: 'Pike', abbreviation: 'Pike'}, + {name: 'Place', abbreviation: 'Pl'}, + {name: 'Plaza', abbreviation: 'Plz'}, + {name: 'Point', abbreviation: 'Pt'}, + {name: 'Ridge', abbreviation: 'Rdg'}, + {name: 'River', abbreviation: 'Riv'}, + {name: 'Road', abbreviation: 'Rd'}, + {name: 'Square', abbreviation: 'Sq'}, + {name: 'Street', abbreviation: 'St'}, + {name: 'Terrace', abbreviation: 'Ter'}, + {name: 'Trail', abbreviation: 'Trl'}, + {name: 'Turnpike', abbreviation: 'Tpke'}, + {name: 'View', abbreviation: 'Vw'}, + {name: 'Way', abbreviation: 'Way'} + ]; + }; + + Chance.prototype.tv = function (options) { + return this.radio(options); }; // 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 = this.n(this.natural, 5, {max: 9}); + var zip = ""; - if (options && options.plusfour === true) { - zip.push('-'); - zip = zip.concat(this.n(this.natural, 4, {max: 9})); + for (var i = 0; i < 5; i++) { + zip += this.natural({max: 9}).toString(); } - return zip.join(""); - }; + if (options && options.plusfour === true) { + zip += '-'; + for (i = 0; i < 4; i++) { + zip += this.natural({max: 9}).toString(); + } + } + + return zip; + }; - // -- End Location -- + // -- End Address -- // -- Time @@ -856,7 +873,21 @@ }; Chance.prototype.months = function () { - return this.get("months"); + return [ + {name: 'January', short_name: 'Jan', numeric: '01', days: 31}, + // Not messing with leap years... + {name: 'February', short_name: 'Feb', numeric: '02', days: 28}, + {name: 'March', short_name: 'Mar', numeric: '03', days: 31}, + {name: 'April', short_name: 'Apr', numeric: '04', days: 30}, + {name: 'May', short_name: 'May', numeric: '05', days: 31}, + {name: 'June', short_name: 'Jun', numeric: '06', days: 30}, + {name: 'July', short_name: 'Jul', numeric: '07', days: 31}, + {name: 'August', short_name: 'Aug', numeric: '08', days: 31}, + {name: 'September', short_name: 'Sep', numeric: '09', days: 30}, + {name: 'October', short_name: 'Oct', numeric: '10', days: 31}, + {name: 'November', short_name: 'Nov', numeric: '11', days: 30}, + {name: 'December', short_name: 'Dec', numeric: '12', days: 31} + ]; }; Chance.prototype.second = function () { @@ -884,17 +915,18 @@ Chance.prototype.cc = function (options) { options = initOptions(options); - var type, number, to_generate; + var type, number, to_generate, type_name; type = (options.type) ? this.cc_type({ name: options.type, raw: true }) : this.cc_type({ raw: true }); - number = type.prefix.split(""); to_generate = type.length - type.prefix.length - 1; // Generates n - 1 digits - number = number.concat(this.n(this.integer, to_generate, {min: 0, max: 9})); + for (var i = 0; i < to_generate; i++) { + number.push(this.integer({min: 0, max: 9})); + } // Generates the last digit according to Luhn algorithm number.push(this.luhn_calculate(number.join(""))); @@ -904,7 +936,25 @@ Chance.prototype.cc_types = function () { // http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29 - return this.get("cc_types"); + return [ + {name: "American Express", short_name: 'amex', prefix: '34', length: 15}, + {name: "Bankcard", short_name: 'bankcard', prefix: '5610', length: 16}, + {name: "China UnionPay", short_name: 'chinaunion', prefix: '62', length: 16}, + {name: "Diners Club Carte Blanche", short_name: 'dccarte', prefix: '300', length: 14}, + {name: "Diners Club enRoute", short_name: 'dcenroute', prefix: '2014', length: 15}, + {name: "Diners Club International", short_name: 'dcintl', prefix: '36', length: 14}, + {name: "Diners Club United States & Canada", short_name: 'dcusc', prefix: '54', length: 16}, + {name: "Discover Card", short_name: 'discover', prefix: '6011', length: 16}, + {name: "InstaPayment", short_name: 'instapay', prefix: '637', length: 16}, + {name: "JCB", short_name: 'jcb', prefix: '3528', length: 16}, + {name: "Laser", short_name: 'laser', prefix: '6304', length: 16}, + {name: "Maestro", short_name: 'maestro', prefix: '5018', length: 16}, + {name: "Mastercard", short_name: 'mc', prefix: '51', length: 16}, + {name: "Solo", short_name: 'solo', prefix: '6334', length: 16}, + {name: "Switch", short_name: 'switch', prefix: '4903', length: 16}, + {name: "Visa", short_name: 'visa', prefix: '4', length: 16}, + {name: "Visa Electron", short_name: 'electron', prefix: '4026', length: 16} + ]; }; Chance.prototype.cc_type = function (options) { @@ -930,35 +980,6 @@ return options.raw ? type : type.name; }; - //return all world currency by ISO 4217 - Chance.prototype.currency_types = function () { - return this.get("currency_types"); - }; - - //return random world currency by ISO 4217 - Chance.prototype.currency = function () { - return this.pick(this.currency_types()); - }; - - //Return random correct currency exchange pair (e.g. EUR/USD) or array of currency code - Chance.prototype.currency_pair = function (returnAsString) { - var currencies = this.unique(this.currency, 2, { - comparator: function(arr, val) { - - return arr.reduce(function(acc, item) { - // If a match has been found, short circuit check and just return - return acc || (item.code === val.code); - }, false); - } - }); - - if (returnAsString) { - return currencies[0] + '/' + currencies[1]; - } else { - return currencies; - } - }; - Chance.prototype.dollar = function (options) { // By default, a somewhat more sane max for dollar than all available numbers options = initOptions(options, {max : 10000, min : 0}); @@ -998,14 +1019,13 @@ Chance.prototype.exp_month = function (options) { options = initOptions(options); - var month, month_int, - curMonth = new Date().getMonth(); + var month, month_int; if (options.future) { do { month = this.month({raw: true}).numeric; month_int = parseInt(month, 10); - } while (month_int < curMonth); + } while (month_int < new Date().getMonth()); } else { month = this.month({raw: true}).numeric; } @@ -1022,20 +1042,14 @@ // -- Miscellaneous -- // Dice - For all the board game geeks out there, myself included ;) - function diceFn (range) { - return function () { - return this.natural(range); - }; - } - Chance.prototype.d4 = diceFn({min: 1, max: 4}); - Chance.prototype.d6 = diceFn({min: 1, max: 6}); - Chance.prototype.d8 = diceFn({min: 1, max: 8}); - Chance.prototype.d10 = diceFn({min: 1, max: 10}); - Chance.prototype.d12 = diceFn({min: 1, max: 12}); - Chance.prototype.d20 = diceFn({min: 1, max: 20}); - Chance.prototype.d30 = diceFn({min: 1, max: 30}); - Chance.prototype.d100 = diceFn({min: 1, max: 100}); - + Chance.prototype.d4 = function () { return this.natural({min: 1, max: 4}); }; + Chance.prototype.d6 = function () { return this.natural({min: 1, max: 6}); }; + Chance.prototype.d8 = function () { return this.natural({min: 1, max: 8}); }; + Chance.prototype.d10 = function () { return this.natural({min: 1, max: 10}); }; + Chance.prototype.d12 = function () { return this.natural({min: 1, max: 12}); }; + Chance.prototype.d20 = function () { return this.natural({min: 1, max: 20}); }; + Chance.prototype.d30 = function () { return this.natural({min: 1, max: 30}); }; + Chance.prototype.d100 = function () { return this.natural({min: 1, max: 100}); }; Chance.prototype.rpg = function (thrown, options) { options = initOptions(options); if (thrown === null) { @@ -1056,22 +1070,22 @@ // Guid Chance.prototype.guid = function (options) { - options = initOptions(options, { version: 5 }); + options = options || {version: 5}; - var guid_pool = "abcdef1234567890", - variant_pool = "ab89", - guid = this.string({ pool: guid_pool, length: 8 }) + '-' + - this.string({ pool: guid_pool, length: 4 }) + '-' + + var guid_pool = "ABCDEF1234567890", + variant_pool = "AB89", + guid = this.string({pool: guid_pool, length: 8}) + '-' + + this.string({pool: guid_pool, length: 4}) + '-' + // The Version options.version + - this.string({ pool: guid_pool, length: 3 }) + '-' + + this.string({pool: guid_pool, length: 3}) + '-' + // The Variant - this.string({ pool: variant_pool, length: 1 }) + - this.string({ pool: guid_pool, length: 3 }) + '-' + - this.string({ pool: guid_pool, length: 12 }); + this.string({pool: variant_pool, length: 1}) + + this.string({pool: guid_pool, length: 3}) + '-' + + this.string({pool: guid_pool, length: 12}); return guid; }; - + // Hash Chance.prototype.hash = function (options) { options = initOptions(options, {length : 40, casing: 'lower'}); @@ -1088,10 +1102,8 @@ Chance.prototype.luhn_calculate = function (num) { var digits = num.toString().split("").reverse(); var sum = 0; - var digit; - for (var i = 0, l = digits.length; l > i; ++i) { - digit = +digits[i]; + var digit = +digits[i]; if (i % 2 === 0) { digit *= 2; if (digit > 9) { @@ -1103,454 +1115,13 @@ return (sum * 9) % 10; }; - - var data = { - - firstNames: { - "male": ["James", "John", "Robert", "Michael", "William", "David", "Richard", "Joseph", "Charles", "Thomas", "Christopher", "Daniel", "Matthew", "George", "Donald", "Anthony", "Paul", "Mark", "Edward", "Steven", "Kenneth", "Andrew", "Brian", "Joshua", "Kevin", "Ronald", "Timothy", "Jason", "Jeffrey", "Frank", "Gary", "Ryan", "Nicholas", "Eric", "Stephen", "Jacob", "Larry", "Jonathan", "Scott", "Raymond", "Justin", "Brandon", "Gregory", "Samuel", "Benjamin", "Patrick", "Jack", "Henry", "Walter", "Dennis", "Jerry", "Alexander", "Peter", "Tyler", "Douglas", "Harold", "Aaron", "Jose", "Adam", "Arthur", "Zachary", "Carl", "Nathan", "Albert", "Kyle", "Lawrence", "Joe", "Willie", "Gerald", "Roger", "Keith", "Jeremy", "Terry", "Harry", "Ralph", "Sean", "Jesse", "Roy", "Louis", "Billy", "Austin", "Bruce", "Eugene", "Christian", "Bryan", "Wayne", "Russell", "Howard", "Fred", "Ethan", "Jordan", "Philip", "Alan", "Juan", "Randy", "Vincent", "Bobby", "Dylan", "Johnny", "Phillip", "Victor", "Clarence", "Ernest", "Martin", "Craig", "Stanley", "Shawn", "Travis", "Bradley", "Leonard", "Earl", "Gabriel", "Jimmy", "Francis", "Todd", "Noah", "Danny", "Dale", "Cody", "Carlos", "Allen", "Frederick", "Logan", "Curtis", "Alex", "Joel", "Luis", "Norman", "Marvin", "Glenn", "Tony", "Nathaniel", "Rodney", "Melvin", "Alfred", "Steve", "Cameron", "Chad", "Edwin", "Caleb", "Evan", "Antonio", "Lee", "Herbert", "Jeffery", "Isaac", "Derek", "Ricky", "Marcus", "Theodore", "Elijah", "Luke", "Jesus", "Eddie", "Troy", "Mike", "Dustin", "Ray", "Adrian", "Bernard", "Leroy", "Angel", "Randall", "Wesley", "Ian", "Jared", "Mason", "Hunter", "Calvin", "Oscar", "Clifford", "Jay", "Shane", "Ronnie", "Barry", "Lucas", "Corey", "Manuel", "Leo", "Tommy", "Warren", "Jackson", "Isaiah", "Connor", "Don", "Dean", "Jon", "Julian", "Miguel", "Bill", "Lloyd", "Charlie", "Mitchell", "Leon", "Jerome", "Darrell", "Jeremiah", "Alvin", "Brett", "Seth", "Floyd", "Jim", "Blake", "Micheal", "Gordon", "Trevor", "Lewis", "Erik", "Edgar", "Vernon", "Devin", "Gavin", "Jayden", "Chris", "Clyde", "Tom", "Derrick", "Mario", "Brent", "Marc", "Herman", "Chase", "Dominic", "Ricardo", "Franklin", "Maurice", "Max", "Aiden", "Owen", "Lester", "Gilbert", "Elmer", "Gene", "Francisco", "Glen", "Cory", "Garrett", "Clayton", "Sam", "Jorge", "Chester", "Alejandro", "Jeff", "Harvey", "Milton", "Cole", "Ivan", "Andre", "Duane", "Landon"], - "female": ["Mary", "Emma", "Elizabeth", "Minnie", "Margaret", "Ida", "Alice", "Bertha", "Sarah", "Annie", "Clara", "Ella", "Florence", "Cora", "Martha", "Laura", "Nellie", "Grace", "Carrie", "Maude", "Mabel", "Bessie", "Jennie", "Gertrude", "Julia", "Hattie", "Edith", "Mattie", "Rose", "Catherine", "Lillian", "Ada", "Lillie", "Helen", "Jessie", "Louise", "Ethel", "Lula", "Myrtle", "Eva", "Frances", "Lena", "Lucy", "Edna", "Maggie", "Pearl", "Daisy", "Fannie", "Josephine", "Dora", "Rosa", "Katherine", "Agnes", "Marie", "Nora", "May", "Mamie", "Blanche", "Stella", "Ellen", "Nancy", "Effie", "Sallie", "Nettie", "Della", "Lizzie", "Flora", "Susie", "Maud", "Mae", "Etta", "Harriet", "Sadie", "Caroline", "Katie", "Lydia", "Elsie", "Kate", "Susan", "Mollie", "Alma", "Addie", "Georgia", "Eliza", "Lulu", "Nannie", "Lottie", "Amanda", "Belle", "Charlotte", "Rebecca", "Ruth", "Viola", "Olive", "Amelia", "Hannah", "Jane", "Virginia", "Emily", "Matilda", "Irene", "Kathryn", "Esther", "Willie", "Henrietta", "Ollie", "Amy", "Rachel", "Sara", "Estella", "Theresa", "Augusta", "Ora", "Pauline", "Josie", "Lola", "Sophia", "Leona", "Anne", "Mildred", "Ann", "Beulah", "Callie", "Lou", "Delia", "Eleanor", "Barbara", "Iva", "Louisa", "Maria", "Mayme", "Evelyn", "Estelle", "Nina", "Betty", "Marion", "Bettie", "Dorothy", "Luella", "Inez", "Lela", "Rosie", "Allie", "Millie", "Janie", "Cornelia", "Victoria", "Ruby", "Winifred", "Alta", "Celia", "Christine", "Beatrice", "Birdie", "Harriett", "Mable", "Myra", "Sophie", "Tillie", "Isabel", "Sylvia", "Carolyn", "Isabelle", "Leila", "Sally", "Ina", "Essie", "Bertie", "Nell", "Alberta", "Katharine", "Lora", "Rena", "Mina", "Rhoda", "Mathilda", "Abbie", "Eula", "Dollie", "Hettie", "Eunice", "Fanny", "Ola", "Lenora", "Adelaide", "Christina", "Lelia", "Nelle", "Sue", "Johanna", "Lilly", "Lucinda", "Minerva", "Lettie", "Roxie", "Cynthia", "Helena", "Hilda", "Hulda", "Bernice", "Genevieve", "Jean", "Cordelia", "Marian", "Francis", "Jeanette", "Adeline", "Gussie", "Leah", "Lois", "Lura", "Mittie", "Hallie", "Isabella", "Olga", "Phoebe", "Teresa", "Hester", "Lida", "Lina", "Winnie", "Claudia", "Marguerite", "Vera", "Cecelia", "Bess", "Emilie", "John", "Rosetta", "Verna", "Myrtie", "Cecilia", "Elva", "Olivia", "Ophelia", "Georgie", "Elnora", "Violet", "Adele", "Lily", "Linnie", "Loretta", "Madge", "Polly", "Virgie", "Eugenia", "Lucile", "Lucille", "Mabelle", "Rosalie"] - }, - - lastNames: ['Smith', 'Johnson', 'Williams', 'Jones', 'Brown', 'Davis', 'Miller', 'Wilson', 'Moore', 'Taylor', 'Anderson', 'Thomas', 'Jackson', 'White', 'Harris', 'Martin', 'Thompson', 'Garcia', 'Martinez', 'Robinson', 'Clark', 'Rodriguez', 'Lewis', 'Lee', 'Walker', 'Hall', 'Allen', 'Young', 'Hernandez', 'King', 'Wright', 'Lopez', 'Hill', 'Scott', 'Green', 'Adams', 'Baker', 'Gonzalez', 'Nelson', 'Carter', 'Mitchell', 'Perez', 'Roberts', 'Turner', 'Phillips', 'Campbell', 'Parker', 'Evans', 'Edwards', 'Collins', 'Stewart', 'Sanchez', 'Morris', 'Rogers', 'Reed', 'Cook', 'Morgan', 'Bell', 'Murphy', 'Bailey', 'Rivera', 'Cooper', 'Richardson', 'Cox', 'Howard', 'Ward', 'Torres', 'Peterson', 'Gray', 'Ramirez', 'James', 'Watson', 'Brooks', 'Kelly', 'Sanders', 'Price', 'Bennett', 'Wood', 'Barnes', 'Ross', 'Henderson', 'Coleman', 'Jenkins', 'Perry', 'Powell', 'Long', 'Patterson', 'Hughes', 'Flores', 'Washington', 'Butler', 'Simmons', 'Foster', 'Gonzales', 'Bryant', 'Alexander', 'Russell', 'Griffin', 'Diaz', 'Hayes', 'Myers', 'Ford', 'Hamilton', 'Graham', 'Sullivan', 'Wallace', 'Woods', 'Cole', 'West', 'Jordan', 'Owens', 'Reynolds', 'Fisher', 'Ellis', 'Harrison', 'Gibson', 'McDonald', 'Cruz', 'Marshall', 'Ortiz', 'Gomez', 'Murray', 'Freeman', 'Wells', 'Webb', 'Simpson', 'Stevens', 'Tucker', 'Porter', 'Hunter', 'Hicks', 'Crawford', 'Henry', 'Boyd', 'Mason', 'Morales', 'Kennedy', 'Warren', 'Dixon', 'Ramos', 'Reyes', 'Burns', 'Gordon', 'Shaw', 'Holmes', 'Rice', 'Robertson', 'Hunt', 'Black', 'Daniels', 'Palmer', 'Mills', 'Nichols', 'Grant', 'Knight', 'Ferguson', 'Rose', 'Stone', 'Hawkins', 'Dunn', 'Perkins', 'Hudson', 'Spencer', 'Gardner', 'Stephens', 'Payne', 'Pierce', 'Berry', 'Matthews', 'Arnold', 'Wagner', 'Willis', 'Ray', 'Watkins', 'Olson', 'Carroll', 'Duncan', 'Snyder', 'Hart', 'Cunningham', 'Bradley', 'Lane', 'Andrews', 'Ruiz', 'Harper', 'Fox', 'Riley', 'Armstrong', 'Carpenter', 'Weaver', 'Greene', 'Lawrence', 'Elliott', 'Chavez', 'Sims', 'Austin', 'Peters', 'Kelley', 'Franklin', 'Lawson', 'Fields', 'Gutierrez', 'Ryan', 'Schmidt', 'Carr', 'Vasquez', 'Castillo', 'Wheeler', 'Chapman', 'Oliver', 'Montgomery', 'Richards', 'Williamson', 'Johnston', 'Banks', 'Meyer', 'Bishop', 'McCoy', 'Howell', 'Alvarez', 'Morrison', 'Hansen', 'Fernandez', 'Garza', 'Harvey', 'Little', 'Burton', 'Stanley', 'Nguyen', 'George', 'Jacobs', 'Reid', 'Kim', 'Fuller', 'Lynch', 'Dean', 'Gilbert', 'Garrett', 'Romero', 'Welch', 'Larson', 'Frazier', 'Burke', 'Hanson', 'Day', 'Mendoza', 'Moreno', 'Bowman', 'Medina', 'Fowler', 'Brewer', 'Hoffman', 'Carlson', 'Silva', 'Pearson', 'Holland', 'Douglas', 'Fleming', 'Jensen', 'Vargas', 'Byrd', 'Davidson', 'Hopkins', 'May', 'Terry', 'Herrera', 'Wade', 'Soto', 'Walters', 'Curtis', 'Neal', 'Caldwell', 'Lowe', 'Jennings', 'Barnett', 'Graves', 'Jimenez', 'Horton', 'Shelton', 'Barrett', 'Obrien', 'Castro', 'Sutton', 'Gregory', 'McKinney', 'Lucas', 'Miles', 'Craig', 'Rodriquez', 'Chambers', 'Holt', 'Lambert', 'Fletcher', 'Watts', 'Bates', 'Hale', 'Rhodes', 'Pena', 'Beck', 'Newman', 'Haynes', 'McDaniel', 'Mendez', 'Bush', 'Vaughn', 'Parks', 'Dawson', 'Santiago', 'Norris', 'Hardy', 'Love', 'Steele', 'Curry', 'Powers', 'Schultz', 'Barker', 'Guzman', 'Page', 'Munoz', 'Ball', 'Keller', 'Chandler', 'Weber', 'Leonard', 'Walsh', 'Lyons', 'Ramsey', 'Wolfe', 'Schneider', 'Mullins', 'Benson', 'Sharp', 'Bowen', 'Daniel', 'Barber', 'Cummings', 'Hines', 'Baldwin', 'Griffith', 'Valdez', 'Hubbard', 'Salazar', 'Reeves', 'Warner', 'Stevenson', 'Burgess', 'Santos', 'Tate', 'Cross', 'Garner', 'Mann', 'Mack', 'Moss', 'Thornton', 'Dennis', 'McGee', 'Farmer', 'Delgado', 'Aguilar', 'Vega', 'Glover', 'Manning', 'Cohen', 'Harmon', 'Rodgers', 'Robbins', 'Newton', 'Todd', 'Blair', 'Higgins', 'Ingram', 'Reese', 'Cannon', 'Strickland', 'Townsend', 'Potter', 'Goodwin', 'Walton', 'Rowe', 'Hampton', 'Ortega', 'Patton', 'Swanson', 'Joseph', 'Francis', 'Goodman', 'Maldonado', 'Yates', 'Becker', 'Erickson', 'Hodges', 'Rios', 'Conner', 'Adkins', 'Webster', 'Norman', 'Malone', 'Hammond', 'Flowers', 'Cobb', 'Moody', 'Quinn', 'Blake', 'Maxwell', 'Pope', 'Floyd', 'Osborne', 'Paul', 'McCarthy', 'Guerrero', 'Lindsey', 'Estrada', 'Sandoval', 'Gibbs', 'Tyler', 'Gross', 'Fitzgerald', 'Stokes', 'Doyle', 'Sherman', 'Saunders', 'Wise', 'Colon', 'Gill', 'Alvarado', 'Greer', 'Padilla', 'Simon', 'Waters', 'Nunez', 'Ballard', 'Schwartz', 'McBride', 'Houston', 'Christensen', 'Klein', 'Pratt', 'Briggs', 'Parsons', 'McLaughlin', 'Zimmerman', 'French', 'Buchanan', 'Moran', 'Copeland', 'Roy', 'Pittman', 'Brady', 'McCormick', 'Holloway', 'Brock', 'Poole', 'Frank', 'Logan', 'Owen', 'Bass', 'Marsh', 'Drake', 'Wong', 'Jefferson', 'Park', 'Morton', 'Abbott', 'Sparks', 'Patrick', 'Norton', 'Huff', 'Clayton', 'Massey', 'Lloyd', 'Figueroa', 'Carson', 'Bowers', 'Roberson', 'Barton', 'Tran', 'Lamb', 'Harrington', 'Casey', 'Boone', 'Cortez', 'Clarke', 'Mathis', 'Singleton', 'Wilkins', 'Cain', 'Bryan', 'Underwood', 'Hogan', 'McKenzie', 'Collier', 'Luna', 'Phelps', 'McGuire', 'Allison', 'Bridges', 'Wilkerson', 'Nash', 'Summers', 'Atkins'], - - provinces: [ - {name: 'Alberta', abbreviation: 'AB'}, - {name: 'British Columbia', abbreviation: 'BC'}, - {name: 'Manitoba', abbreviation: 'MB'}, - {name: 'New Brunswick', abbreviation: 'NB'}, - {name: 'Newfoundland and Labrador', abbreviation: 'NL'}, - {name: 'Nova Scotia', abbreviation: 'NS'}, - {name: 'Ontario', abbreviation: 'ON'}, - {name: 'Prince Edward Island', abbreviation: 'PE'}, - {name: 'Quebec', abbreviation: 'QC'}, - {name: 'Saskatchewan', abbreviation: 'SK'}, - - // The case could be made that the following are not actually provinces - // since they are technically considered "territories" however they all - // look the same on an envelope! - {name: 'Northwest Territories', abbreviation: 'NT'}, - {name: 'Nunavut', abbreviation: 'NU'}, - {name: 'Yukon', abbreviation: 'YT'} - ], - - us_states_and_dc: [ - {name: 'Alabama', abbreviation: 'AL'}, - {name: 'Alaska', abbreviation: 'AK'}, - {name: 'Arizona', abbreviation: 'AZ'}, - {name: 'Arkansas', abbreviation: 'AR'}, - {name: 'California', abbreviation: 'CA'}, - {name: 'Colorado', abbreviation: 'CO'}, - {name: 'Connecticut', abbreviation: 'CT'}, - {name: 'Delaware', abbreviation: 'DE'}, - {name: 'District of Columbia', abbreviation: 'DC'}, - {name: 'Florida', abbreviation: 'FL'}, - {name: 'Georgia', abbreviation: 'GA'}, - {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: '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: 'Ohio', abbreviation: 'OH'}, - {name: 'Oklahoma', abbreviation: 'OK'}, - {name: 'Oregon', abbreviation: 'OR'}, - {name: 'Pennsylvania', abbreviation: 'PA'}, - {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: 'Virginia', abbreviation: 'VA'}, - {name: 'Washington', abbreviation: 'WA'}, - {name: 'West Virginia', abbreviation: 'WV'}, - {name: 'Wisconsin', abbreviation: 'WI'}, - {name: 'Wyoming', abbreviation: 'WY'} - ], - - territories: [ - {name: 'American Samoa', abbreviation: 'AS'}, - {name: 'Federated States of Micronesia', abbreviation: 'FM'}, - {name: 'Guam', abbreviation: 'GU'}, - {name: 'Marshall Islands', abbreviation: 'MH'}, - {name: 'Northern Mariana Islands', abbreviation: 'MP'}, - {name: 'Puerto Rico', abbreviation: 'PR'}, - {name: 'Virgin Islands, U.S.', abbreviation: 'VI'} - ], - - armed_forces: [ - {name: 'Armed Forces Europe', abbreviation: 'AE'}, - {name: 'Armed Forces Pacific', abbreviation: 'AP'}, - {name: 'Armed Forces the Americas', abbreviation: 'AA'} - ], - - street_suffixes: [ - {name: 'Avenue', abbreviation: 'Ave'}, - {name: 'Boulevard', abbreviation: 'Blvd'}, - {name: 'Center', abbreviation: 'Ctr'}, - {name: 'Circle', abbreviation: 'Cir'}, - {name: 'Court', abbreviation: 'Ct'}, - {name: 'Drive', abbreviation: 'Dr'}, - {name: 'Extension', abbreviation: 'Ext'}, - {name: 'Glen', abbreviation: 'Gln'}, - {name: 'Grove', abbreviation: 'Grv'}, - {name: 'Heights', abbreviation: 'Hts'}, - {name: 'Highway', abbreviation: 'Hwy'}, - {name: 'Junction', abbreviation: 'Jct'}, - {name: 'Key', abbreviation: 'Key'}, - {name: 'Lane', abbreviation: 'Ln'}, - {name: 'Loop', abbreviation: 'Loop'}, - {name: 'Manor', abbreviation: 'Mnr'}, - {name: 'Mill', abbreviation: 'Mill'}, - {name: 'Park', abbreviation: 'Park'}, - {name: 'Parkway', abbreviation: 'Pkwy'}, - {name: 'Pass', abbreviation: 'Pass'}, - {name: 'Path', abbreviation: 'Path'}, - {name: 'Pike', abbreviation: 'Pike'}, - {name: 'Place', abbreviation: 'Pl'}, - {name: 'Plaza', abbreviation: 'Plz'}, - {name: 'Point', abbreviation: 'Pt'}, - {name: 'Ridge', abbreviation: 'Rdg'}, - {name: 'River', abbreviation: 'Riv'}, - {name: 'Road', abbreviation: 'Rd'}, - {name: 'Square', abbreviation: 'Sq'}, - {name: 'Street', abbreviation: 'St'}, - {name: 'Terrace', abbreviation: 'Ter'}, - {name: 'Trail', abbreviation: 'Trl'}, - {name: 'Turnpike', abbreviation: 'Tpke'}, - {name: 'View', abbreviation: 'Vw'}, - {name: 'Way', abbreviation: 'Way'} - ], - - months: [ - {name: 'January', short_name: 'Jan', numeric: '01', days: 31}, - // Not messing with leap years... - {name: 'February', short_name: 'Feb', numeric: '02', days: 28}, - {name: 'March', short_name: 'Mar', numeric: '03', days: 31}, - {name: 'April', short_name: 'Apr', numeric: '04', days: 30}, - {name: 'May', short_name: 'May', numeric: '05', days: 31}, - {name: 'June', short_name: 'Jun', numeric: '06', days: 30}, - {name: 'July', short_name: 'Jul', numeric: '07', days: 31}, - {name: 'August', short_name: 'Aug', numeric: '08', days: 31}, - {name: 'September', short_name: 'Sep', numeric: '09', days: 30}, - {name: 'October', short_name: 'Oct', numeric: '10', days: 31}, - {name: 'November', short_name: 'Nov', numeric: '11', days: 30}, - {name: 'December', short_name: 'Dec', numeric: '12', days: 31} - ], - - // http://en.wikipedia.org/wiki/Bank_card_number#Issuer_identification_number_.28IIN.29 - cc_types: [ - {name: "American Express", short_name: 'amex', prefix: '34', length: 15}, - {name: "Bankcard", short_name: 'bankcard', prefix: '5610', length: 16}, - {name: "China UnionPay", short_name: 'chinaunion', prefix: '62', length: 16}, - {name: "Diners Club Carte Blanche", short_name: 'dccarte', prefix: '300', length: 14}, - {name: "Diners Club enRoute", short_name: 'dcenroute', prefix: '2014', length: 15}, - {name: "Diners Club International", short_name: 'dcintl', prefix: '36', length: 14}, - {name: "Diners Club United States & Canada", short_name: 'dcusc', prefix: '54', length: 16}, - {name: "Discover Card", short_name: 'discover', prefix: '6011', length: 16}, - {name: "InstaPayment", short_name: 'instapay', prefix: '637', length: 16}, - {name: "JCB", short_name: 'jcb', prefix: '3528', length: 16}, - {name: "Laser", short_name: 'laser', prefix: '6304', length: 16}, - {name: "Maestro", short_name: 'maestro', prefix: '5018', length: 16}, - {name: "Mastercard", short_name: 'mc', prefix: '51', length: 16}, - {name: "Solo", short_name: 'solo', prefix: '6334', length: 16}, - {name: "Switch", short_name: 'switch', prefix: '4903', length: 16}, - {name: "Visa", short_name: 'visa', prefix: '4', length: 16}, - {name: "Visa Electron", short_name: 'electron', prefix: '4026', length: 16} - ], - - //return all world currency by ISO 4217 - currency_types: [ - {'code' : 'AED', 'name' : 'United Arab Emirates Dirham'}, - {'code' : 'AFN', 'name' : 'Afghanistan Afghani'}, - {'code' : 'ALL', 'name' : 'Albania Lek'}, - {'code' : 'AMD', 'name' : 'Armenia Dram'}, - {'code' : 'ANG', 'name' : 'Netherlands Antilles Guilder'}, - {'code' : 'AOA', 'name' : 'Angola Kwanza'}, - {'code' : 'ARS', 'name' : 'Argentina Peso'}, - {'code' : 'AUD', 'name' : 'Australia Dollar'}, - {'code' : 'AWG', 'name' : 'Aruba Guilder'}, - {'code' : 'AZN', 'name' : 'Azerbaijan New Manat'}, - {'code' : 'BAM', 'name' : 'Bosnia and Herzegovina Convertible Marka'}, - {'code' : 'BBD', 'name' : 'Barbados Dollar'}, - {'code' : 'BDT', 'name' : 'Bangladesh Taka'}, - {'code' : 'BGN', 'name' : 'Bulgaria Lev'}, - {'code' : 'BHD', 'name' : 'Bahrain Dinar'}, - {'code' : 'BIF', 'name' : 'Burundi Franc'}, - {'code' : 'BMD', 'name' : 'Bermuda Dollar'}, - {'code' : 'BND', 'name' : 'Brunei Darussalam Dollar'}, - {'code' : 'BOB', 'name' : 'Bolivia Boliviano'}, - {'code' : 'BRL', 'name' : 'Brazil Real'}, - {'code' : 'BSD', 'name' : 'Bahamas Dollar'}, - {'code' : 'BTN', 'name' : 'Bhutan Ngultrum'}, - {'code' : 'BWP', 'name' : 'Botswana Pula'}, - {'code' : 'BYR', 'name' : 'Belarus Ruble'}, - {'code' : 'BZD', 'name' : 'Belize Dollar'}, - {'code' : 'CAD', 'name' : 'Canada Dollar'}, - {'code' : 'CDF', 'name' : 'Congo/Kinshasa Franc'}, - {'code' : 'CHF', 'name' : 'Switzerland Franc'}, - {'code' : 'CLP', 'name' : 'Chile Peso'}, - {'code' : 'CNY', 'name' : 'China Yuan Renminbi'}, - {'code' : 'COP', 'name' : 'Colombia Peso'}, - {'code' : 'CRC', 'name' : 'Costa Rica Colon'}, - {'code' : 'CUC', 'name' : 'Cuba Convertible Peso'}, - {'code' : 'CUP', 'name' : 'Cuba Peso'}, - {'code' : 'CVE', 'name' : 'Cape Verde Escudo'}, - {'code' : 'CZK', 'name' : 'Czech Republic Koruna'}, - {'code' : 'DJF', 'name' : 'Djibouti Franc'}, - {'code' : 'DKK', 'name' : 'Denmark Krone'}, - {'code' : 'DOP', 'name' : 'Dominican Republic Peso'}, - {'code' : 'DZD', 'name' : 'Algeria Dinar'}, - {'code' : 'EGP', 'name' : 'Egypt Pound'}, - {'code' : 'ERN', 'name' : 'Eritrea Nakfa'}, - {'code' : 'ETB', 'name' : 'Ethiopia Birr'}, - {'code' : 'EUR', 'name' : 'Euro Member Countries'}, - {'code' : 'FJD', 'name' : 'Fiji Dollar'}, - {'code' : 'FKP', 'name' : 'Falkland Islands (Malvinas) Pound'}, - {'code' : 'GBP', 'name' : 'United Kingdom Pound'}, - {'code' : 'GEL', 'name' : 'Georgia Lari'}, - {'code' : 'GGP', 'name' : 'Guernsey Pound'}, - {'code' : 'GHS', 'name' : 'Ghana Cedi'}, - {'code' : 'GIP', 'name' : 'Gibraltar Pound'}, - {'code' : 'GMD', 'name' : 'Gambia Dalasi'}, - {'code' : 'GNF', 'name' : 'Guinea Franc'}, - {'code' : 'GTQ', 'name' : 'Guatemala Quetzal'}, - {'code' : 'GYD', 'name' : 'Guyana Dollar'}, - {'code' : 'HKD', 'name' : 'Hong Kong Dollar'}, - {'code' : 'HNL', 'name' : 'Honduras Lempira'}, - {'code' : 'HRK', 'name' : 'Croatia Kuna'}, - {'code' : 'HTG', 'name' : 'Haiti Gourde'}, - {'code' : 'HUF', 'name' : 'Hungary Forint'}, - {'code' : 'IDR', 'name' : 'Indonesia Rupiah'}, - {'code' : 'ILS', 'name' : 'Israel Shekel'}, - {'code' : 'IMP', 'name' : 'Isle of Man Pound'}, - {'code' : 'INR', 'name' : 'India Rupee'}, - {'code' : 'IQD', 'name' : 'Iraq Dinar'}, - {'code' : 'IRR', 'name' : 'Iran Rial'}, - {'code' : 'ISK', 'name' : 'Iceland Krona'}, - {'code' : 'JEP', 'name' : 'Jersey Pound'}, - {'code' : 'JMD', 'name' : 'Jamaica Dollar'}, - {'code' : 'JOD', 'name' : 'Jordan Dinar'}, - {'code' : 'JPY', 'name' : 'Japan Yen'}, - {'code' : 'KES', 'name' : 'Kenya Shilling'}, - {'code' : 'KGS', 'name' : 'Kyrgyzstan Som'}, - {'code' : 'KHR', 'name' : 'Cambodia Riel'}, - {'code' : 'KMF', 'name' : 'Comoros Franc'}, - {'code' : 'KPW', 'name' : 'Korea (North) Won'}, - {'code' : 'KRW', 'name' : 'Korea (South) Won'}, - {'code' : 'KWD', 'name' : 'Kuwait Dinar'}, - {'code' : 'KYD', 'name' : 'Cayman Islands Dollar'}, - {'code' : 'KZT', 'name' : 'Kazakhstan Tenge'}, - {'code' : 'LAK', 'name' : 'Laos Kip'}, - {'code' : 'LBP', 'name' : 'Lebanon Pound'}, - {'code' : 'LKR', 'name' : 'Sri Lanka Rupee'}, - {'code' : 'LRD', 'name' : 'Liberia Dollar'}, - {'code' : 'LSL', 'name' : 'Lesotho Loti'}, - {'code' : 'LTL', 'name' : 'Lithuania Litas'}, - {'code' : 'LYD', 'name' : 'Libya Dinar'}, - {'code' : 'MAD', 'name' : 'Morocco Dirham'}, - {'code' : 'MDL', 'name' : 'Moldova Leu'}, - {'code' : 'MGA', 'name' : 'Madagascar Ariary'}, - {'code' : 'MKD', 'name' : 'Macedonia Denar'}, - {'code' : 'MMK', 'name' : 'Myanmar (Burma) Kyat'}, - {'code' : 'MNT', 'name' : 'Mongolia Tughrik'}, - {'code' : 'MOP', 'name' : 'Macau Pataca'}, - {'code' : 'MRO', 'name' : 'Mauritania Ouguiya'}, - {'code' : 'MUR', 'name' : 'Mauritius Rupee'}, - {'code' : 'MVR', 'name' : 'Maldives (Maldive Islands) Rufiyaa'}, - {'code' : 'MWK', 'name' : 'Malawi Kwacha'}, - {'code' : 'MXN', 'name' : 'Mexico Peso'}, - {'code' : 'MYR', 'name' : 'Malaysia Ringgit'}, - {'code' : 'MZN', 'name' : 'Mozambique Metical'}, - {'code' : 'NAD', 'name' : 'Namibia Dollar'}, - {'code' : 'NGN', 'name' : 'Nigeria Naira'}, - {'code' : 'NIO', 'name' : 'Nicaragua Cordoba'}, - {'code' : 'NOK', 'name' : 'Norway Krone'}, - {'code' : 'NPR', 'name' : 'Nepal Rupee'}, - {'code' : 'NZD', 'name' : 'New Zealand Dollar'}, - {'code' : 'OMR', 'name' : 'Oman Rial'}, - {'code' : 'PAB', 'name' : 'Panama Balboa'}, - {'code' : 'PEN', 'name' : 'Peru Nuevo Sol'}, - {'code' : 'PGK', 'name' : 'Papua New Guinea Kina'}, - {'code' : 'PHP', 'name' : 'Philippines Peso'}, - {'code' : 'PKR', 'name' : 'Pakistan Rupee'}, - {'code' : 'PLN', 'name' : 'Poland Zloty'}, - {'code' : 'PYG', 'name' : 'Paraguay Guarani'}, - {'code' : 'QAR', 'name' : 'Qatar Riyal'}, - {'code' : 'RON', 'name' : 'Romania New Leu'}, - {'code' : 'RSD', 'name' : 'Serbia Dinar'}, - {'code' : 'RUB', 'name' : 'Russia Ruble'}, - {'code' : 'RWF', 'name' : 'Rwanda Franc'}, - {'code' : 'SAR', 'name' : 'Saudi Arabia Riyal'}, - {'code' : 'SBD', 'name' : 'Solomon Islands Dollar'}, - {'code' : 'SCR', 'name' : 'Seychelles Rupee'}, - {'code' : 'SDG', 'name' : 'Sudan Pound'}, - {'code' : 'SEK', 'name' : 'Sweden Krona'}, - {'code' : 'SGD', 'name' : 'Singapore Dollar'}, - {'code' : 'SHP', 'name' : 'Saint Helena Pound'}, - {'code' : 'SLL', 'name' : 'Sierra Leone Leone'}, - {'code' : 'SOS', 'name' : 'Somalia Shilling'}, - {'code' : 'SPL', 'name' : 'Seborga Luigino'}, - {'code' : 'SRD', 'name' : 'Suriname Dollar'}, - {'code' : 'STD', 'name' : 'São Tomé and Príncipe Dobra'}, - {'code' : 'SVC', 'name' : 'El Salvador Colon'}, - {'code' : 'SYP', 'name' : 'Syria Pound'}, - {'code' : 'SZL', 'name' : 'Swaziland Lilangeni'}, - {'code' : 'THB', 'name' : 'Thailand Baht'}, - {'code' : 'TJS', 'name' : 'Tajikistan Somoni'}, - {'code' : 'TMT', 'name' : 'Turkmenistan Manat'}, - {'code' : 'TND', 'name' : 'Tunisia Dinar'}, - {'code' : 'TOP', 'name' : 'Tonga Pa\'anga'}, - {'code' : 'TRY', 'name' : 'Turkey Lira'}, - {'code' : 'TTD', 'name' : 'Trinidad and Tobago Dollar'}, - {'code' : 'TVD', 'name' : 'Tuvalu Dollar'}, - {'code' : 'TWD', 'name' : 'Taiwan New Dollar'}, - {'code' : 'TZS', 'name' : 'Tanzania Shilling'}, - {'code' : 'UAH', 'name' : 'Ukraine Hryvnia'}, - {'code' : 'UGX', 'name' : 'Uganda Shilling'}, - {'code' : 'USD', 'name' : 'United States Dollar'}, - {'code' : 'UYU', 'name' : 'Uruguay Peso'}, - {'code' : 'UZS', 'name' : 'Uzbekistan Som'}, - {'code' : 'VEF', 'name' : 'Venezuela Bolivar'}, - {'code' : 'VND', 'name' : 'Viet Nam Dong'}, - {'code' : 'VUV', 'name' : 'Vanuatu Vatu'}, - {'code' : 'WST', 'name' : 'Samoa Tala'}, - {'code' : 'XAF', 'name' : 'Communauté Financière Africaine (BEAC) CFA Franc BEAC'}, - {'code' : 'XCD', 'name' : 'East Caribbean Dollar'}, - {'code' : 'XDR', 'name' : 'International Monetary Fund (IMF) Special Drawing Rights'}, - {'code' : 'XOF', 'name' : 'Communauté Financière Africaine (BCEAO) Franc'}, - {'code' : 'XPF', 'name' : 'Comptoirs Français du Pacifique (CFP) Franc'}, - {'code' : 'YER', 'name' : 'Yemen Rial'}, - {'code' : 'ZAR', 'name' : 'South Africa Rand'}, - {'code' : 'ZMW', 'name' : 'Zambia Kwacha'}, - {'code' : 'ZWD', 'name' : 'Zimbabwe Dollar'} - ] - }; - - function copyObject(source, target) { - var key; - - target = target || (Array.isArray(source) ? [] : {}); - - for (key in source) { - if (source.hasOwnProperty(key)) { - target[key] = source[key] || target[key]; - } - } - - return target; - } - - /** Get the data based on key**/ - Chance.prototype.get = function (name) { - return copyObject(data[name]); - }; - - // Mac Address - Chance.prototype.mac_address = function(options){ - // typically mac addresses are separated by ":" - // however they can also be separated by "-" - // the network variant uses a dot every fourth byte - - options = initOptions(options); - if(!options.separator) { - options.separator = options.networkVersion ? "." : ":"; - } - - var mac_pool="ABCDEF1234567890", - mac = ""; - if(!options.networkVersion) { - mac = this.n(this.string, 6, { pool: mac_pool, length:2 }).join(options.separator); - } else { - mac = this.n(this.string, 3, { pool: mac_pool, length:4 }).join(options.separator); - } - - return mac; - }; - - Chance.prototype.normal = function (options) { - options = initOptions(options, {mean : 0, dev : 1}); - - // The Marsaglia Polar method - var s, u, v, norm, - mean = options.mean, - dev = options.dev; - - do { - // U and V are from the uniform distribution on (-1, 1) - u = this.random() * 2 - 1; - v = this.random() * 2 - 1; - - s = u * u + v * v; - } while (s >= 1); - - // Compute the standard normal variate - norm = u * Math.sqrt(-2 * Math.log(s) / s); - - // Shape and scale - return dev * norm + mean; - }; - - Chance.prototype.radio = function (options) { - // Initial Letter (Typically Designated by Side of Mississippi River) - options = initOptions(options, {side : "?"}); - var fl = ""; - switch (options.side.toLowerCase()) { - case "east": - case "e": - fl = "W"; - break; - case "west": - case "w": - fl = "K"; - break; - default: - fl = this.character({pool: "KW"}); - break; - } - - return fl + this.character({alpha: true, casing: "upper"}) + - this.character({alpha: true, casing: "upper"}) + - this.character({alpha: true, casing: "upper"}); - }; - - // Set the data as key and data or the data map - Chance.prototype.set = function (name, values) { - if (typeof name === "string") { - data[name] = values; - } else { - data = copyObject(name, data); - } - }; - - Chance.prototype.tv = function (options) { - return this.radio(options); + Chance.prototype.mersenne_twister = function (seed) { + return new MersenneTwister(seed); }; // -- End Miscellaneous -- - Chance.prototype.mersenne_twister = function (seed) { - return new MersenneTwister(seed); - }; + Chance.prototype.VERSION = "0.5.5"; // Mersenne Twister from https://gist.github.com/banksean/300494 var MersenneTwister = function (seed) { diff --git a/examples/tech-radar.js b/examples/tech-radar.js deleted file mode 100644 index 8f26cb2..0000000 --- a/examples/tech-radar.js +++ /dev/null @@ -1,440 +0,0 @@ -/** - * tech-radar - * @version v0.1.6 - */ -var tr = tr || {}; -tr.models = {}; -tr.graphing = {}; -tr.util = {}; - -tr.graphing.Radar = function (size, radar) { - var self, fib, svg; - - fib = new tr.util.Fib(); - - self = {}; - self.svg = function () { - return svg; - } - - function center () { - return Math.round(size/2); - } - - function plotLines() { - svg.append('line') - .attr('x1', center()) - .attr('y1', 0) - .attr('x2', center()) - .attr('y2', size) - .attr('stroke-width', 14); - - svg.append('line') - .attr('x1', 0) - .attr('y1', center()) - .attr('x2', size) - .attr('y2', center()) - .attr('stroke-width', 14); - }; - - function getRadius(cycles, i) { - var sequence = fib.sequence(cycles.length); - var total = fib.sum(cycles.length); - var sum = fib.sum(i); - - return center() - (center() * sum / total); - } - - function plotCircles(cycles) { - var increment; - - cycles.forEach(function (cycle, i) { - svg.append('circle') - .attr('cx', center()) - .attr('cy', center()) - .attr('r', getRadius(cycles, i)); - }); - } - - function plotTexts(cycles) { - var increment; - - increment = Math.round(center() / cycles.length); - - cycles.forEach(function (cycle, i) { - svg.append('text') - .attr('class', 'line-text') - .attr('y', center() + 4) - .attr('x', center() - getRadius(cycles, i) + 10) - .text(cycle.name()); - - svg.append('text') - .attr('class', 'line-text') - .attr('y', center() + 4) - .attr('x', center() + getRadius(cycles, i) - 10) - .attr('text-anchor', 'end') - .text(cycle.name()); - }); - }; - - function triangle(x, y, cssClass) { - var tsize, top, left, right, bottom, points; - - tsize = 13 - top = y - tsize; - left = (x - tsize + 1); - right = (x + tsize + 1); - bottom = (y + tsize - tsize / 2.5); - - points = x + 1 + ',' + top + ' ' + left + ',' + bottom + ' ' + right + ',' + bottom; - - return svg.append('polygon') - .attr('points', points) - .attr('class', cssClass) - .attr('stroke-width', 1.5); - } - - function circle(x, y, cssClass) { - svg.append('circle') - .attr('cx', x) - .attr('cy', y) - .attr('class', cssClass) - .attr('stroke-width', 1.5) - .attr('r', 10); - } - - function plotBlips(cycles, quadrant, adjustX, adjustY, cssClass) { - var blips; - blips = quadrant.blips(); - cycles.forEach(function (cycle, i) { - var maxRadius, minRadius, cycleBlips; - - maxRadius = getRadius(cycles, i); - minRadius = (i == cycles.length - 1) ? 0: getRadius(cycles, i + 1); - - var cycleBlips = blips.filter(function (blip) { - return blip.cycle() == cycle; - }); - - cycleBlips.forEach(function (blip) { - var angleInRad, radius; - - var split = blip.name().split(''); - var sum = split.reduce(function (p, c) { return p + c.charCodeAt(0); }, 0); - chance = new Chance(sum * cycle.name().length * blip.number()); - - angleInRad = Math.PI * chance.integer({ min: 13, max: 85 }) / 180; - radius = chance.floating({ min: minRadius + 25, max: maxRadius - 10 }); - - var x = center() + radius * Math.cos(angleInRad) * adjustX; - var y = center() + radius * Math.sin(angleInRad) * adjustY; - - if (blip.isNew()) { - triangle(x, y, cssClass); - } else { - circle(x, y, cssClass); - } - - svg.append('text') - .attr('x', x) - .attr('y', y + 4) - .attr('class', 'blip-text') - .attr('text-anchor', 'middle') - .text(blip.number()) - }); - }); - }; - - function plotQuadrantNames(quadrants) { - function plotName(name, anchor, x, y, cssClass) { - svg.append('text') - .attr('x', x) - .attr('y', y) - .attr('class', cssClass) - .attr('text-anchor', anchor) - .text(name); - } - - plotName(quadrants.I.name(), 'end', size - 10, 10, 'first') - plotName(quadrants.II.name(), 'start', 10, 10, 'second') - plotName(quadrants.III.name(), 'start', 10, size - 10, 'third') - plotName(quadrants.IV.name(), 'end', size -10, size - 10, 'fourth') - } - - self.init = function (selector) { - svg = d3.select(selector || 'body').append("svg"); - return self; - }; - - self.plot = function () { - var cycles, quadrants; - - cycles = radar.cycles().reverse(); - quadrants = radar.quadrants(); - - svg.attr('width', size).attr('height', size); - - plotCircles(cycles); - plotLines(); - plotTexts(cycles); - - if (radar.hasQuadrants()) { - plotQuadrantNames(quadrants); - plotBlips(cycles, quadrants.I, 1, -1, 'first'); - plotBlips(cycles, quadrants.II, -1, -1, 'second'); - plotBlips(cycles, quadrants.III, -1, 1, 'third'); - plotBlips(cycles, quadrants.IV, 1, 1, 'fourth'); - } - }; - - return self; -}; - -tr.graphing.RefTable = function (radar) { - var self = {}; - var injectionElement; - - function blipsByCycle () { - // set up empty blip arrays for each cycle - var cycles = {}; - radar.cycles() - .map(function (cycle) { - return { - order: cycle.order(), - name: cycle.name() - }; - }) - .sort(function (a, b) { - if (a.order === b.order) { - return 0; - } else if (a.order < b.order) { - return -1; - } else { - return 1; - } - }) - .forEach(function (cycle) { - cycles[cycle.name] = []; - }); - - // group blips by cycle - var blips = []; - var quadrants = radar.quadrants(); - Object.keys(quadrants).forEach(function (quadrant) { - blips = blips.concat(quadrants[quadrant].blips()); - }); - - blips.forEach(function (blip) { - cycles[blip.cycle().name()].push(blip); - }); - - return cycles; - } - - self.init = function (selector) { - injectionElement = document.querySelector(selector || 'body'); - return self; - }; - - self.render = function () { - var blips = blipsByCycle(); - - var html = ''; - - Object.keys(blips).forEach(function (cycle) { - html += ''; - - blips[cycle].forEach(function (blip) { - html += '' + - '' + - '' + - '' + - ''; - }); - }); - - html += '
' + cycle + '
' + blip.number() + '' + blip.name() + '' + blip.description() + '
'; - - injectionElement.innerHTML = html; - }; - - return self; -}; - -tr.models.Blip = function (name, cycle, isNew, description) { - var self, number; - - self = {}; - number = -1; - - self.name = function () { - return name; - }; - - self.description = function () { - return description || ''; - }; - - self.isNew = function () { - return isNew; - }; - - self.cycle = function () { - return cycle; - }; - - self.number = function () { - return number; - }; - - self.setNumber = function (newNumber) { - number = newNumber; - }; - - return self; -}; - -tr.models.Cycle = function (name, order) { - var self = {}; - - self.name = function () { - return name; - }; - - self.order = function () { - return order; - }; - - return self; -}; - -tr.models.Quadrant = function (name) { - var self, blips; - - self = {}; - blips = []; - - self.name = function () { - return name; - }; - - self.add = function (newBlips) { - if (Array.isArray(newBlips)) { - blips = blips.concat(newBlips); - } else { - blips.push(newBlips); - } - }; - - self.blips = function () { - return blips.slice(0); - }; - - return self; -}; - -tr.models.Radar = function() { - var self, quadrants, blipNumber; - - blipNumber = 0; - quadrants = { I: null, II: null, III: null, IV: null }; - self = {}; - - function setNumbers(blips) { - blips.forEach(function (blip) { - blip.setNumber(++blipNumber); - }); - } - - self.setFirstQuadrant = function (quadrant) { - quadrants.I = quadrant; - setNumbers(quadrants.I.blips()); - }; - - self.setSecondQuadrant = function (quadrant) { - quadrants.II = quadrant; - setNumbers(quadrants.II.blips()); - }; - - self.setThirdQuadrant = function (quadrant) { - quadrants.III = quadrant; - setNumbers(quadrants.III.blips()); - }; - - self.setFourthQuadrant = function (quadrant) { - quadrants.IV = quadrant; - setNumbers(quadrants.IV.blips()); - }; - - function allQuadrants() { - var all = []; - - for (var p in quadrants) { - if (quadrants.hasOwnProperty(p) && quadrants[p] != null) { - all.push(quadrants[p]); - } - } - - return all; - } - - function allBlips() { - return allQuadrants().reduce(function (blips, quadrant) { - return blips.concat(quadrant.blips()); - }, []); - } - - self.hasQuadrants = function () { - return !!quadrants.I || !!quadrants.II || !!quadrants.III || !!quadrants.IV; - } - - self.cycles = function () { - var cycleHash, cycleArray; - - cycleArray = []; - cycleHash = {}; - - allBlips().forEach(function (blip) { - cycleHash[blip.cycle().name()] = blip.cycle(); - }); - - for (var p in cycleHash) { - if (cycleHash.hasOwnProperty(p)) { - cycleArray.push(cycleHash[p]); - } - } - - return cycleArray.slice(0).sort(function (a, b) { return a.order() - b.order(); }); - }; - - self.quadrants = function () { - return quadrants; - }; - - return self; -}; - -tr.util.Fib = function () { - var self = {}; - - self.sequence = function (length) { - var result = [0, 1]; - - for (var i = 2; i < length; i++) { - result[i] = result[i-2] + result[i-1]; - } - - return result; - }; - - self.sum = function (length) { - if (length === 0) { return 0; } - if (length === 1) { return 1; } - - return self.sequence(length + 1).reduce(function (previous, current) { - return previous + current; - }, 0); - }; - - return self; -}; diff --git a/examples/tech-radar.min.js b/examples/tech-radar.min.js index 436a84d..f2cf450 100644 --- a/examples/tech-radar.min.js +++ b/examples/tech-radar.min.js @@ -1,5 +1,2 @@ -/** - * tech-radar - * @version v0.1.6 - */ -var tr=tr||{};tr.models={},tr.graphing={},tr.util={},tr.graphing.Radar=function(t,n){function r(){return Math.round(t/2)}function e(){h.append("line").attr("x1",r()).attr("y1",0).attr("x2",r()).attr("y2",t).attr("stroke-width",14),h.append("line").attr("x1",0).attr("y1",r()).attr("x2",t).attr("y2",r()).attr("stroke-width",14)}function a(t,n){var e=(l.sequence(t.length),l.sum(t.length)),a=l.sum(n);return r()-r()*a/e}function u(t){t.forEach(function(n,e){h.append("circle").attr("cx",r()).attr("cy",r()).attr("r",a(t,e))})}function c(t){var n;n=Math.round(r()/t.length),t.forEach(function(n,e){h.append("text").attr("class","line-text").attr("y",r()+4).attr("x",r()-a(t,e)+10).text(n.name()),h.append("text").attr("class","line-text").attr("y",r()+4).attr("x",r()+a(t,e)-10).attr("text-anchor","end").text(n.name())})}function o(t,n,r){var e,a,u,c,o,i;return e=13,a=n-e,u=t-e+1,c=t+e+1,o=n+e-e/2.5,i=t+1+","+a+" "+u+","+o+" "+c+","+o,h.append("polygon").attr("points",i).attr("class",r).attr("stroke-width",1.5)}function i(t,n,r){h.append("circle").attr("cx",t).attr("cy",n).attr("class",r).attr("stroke-width",1.5).attr("r",10)}function s(t,n,e,u,c){var s;s=n.blips(),t.forEach(function(n,f){var d,l,p;d=a(t,f),l=f==t.length-1?0:a(t,f+1);var p=s.filter(function(t){return t.cycle()==n});p.forEach(function(t){var a,s,f=t.name().split(""),p=f.reduce(function(t,n){return t+n.charCodeAt(0)},0);chance=new Chance(p*n.name().length*t.number()),a=Math.PI*chance.integer({min:13,max:85})/180,s=chance.floating({min:l+25,max:d-10});var I=r()+s*Math.cos(a)*e,m=r()+s*Math.sin(a)*u;t.isNew()?o(I,m,c):i(I,m,c),h.append("text").attr("x",I).attr("y",m+4).attr("class","blip-text").attr("text-anchor","middle").text(t.number())})})}function f(n){function r(t,n,r,e,a){h.append("text").attr("x",r).attr("y",e).attr("class",a).attr("text-anchor",n).text(t)}r(n.I.name(),"end",t-10,10,"first"),r(n.II.name(),"start",10,10,"second"),r(n.III.name(),"start",10,t-10,"third"),r(n.IV.name(),"end",t-10,t-10,"fourth")}var d,l,h;return l=new tr.util.Fib,d={},d.svg=function(){return h},d.init=function(t){return h=d3.select(t||"body").append("svg"),d},d.plot=function(){var r,a;r=n.cycles().reverse(),a=n.quadrants(),h.attr("width",t).attr("height",t),u(r),e(),c(r),n.hasQuadrants()&&(f(a),s(r,a.I,1,-1,"first"),s(r,a.II,-1,-1,"second"),s(r,a.III,-1,1,"third"),s(r,a.IV,1,1,"fourth"))},d},tr.graphing.RefTable=function(t){function n(){var n={};t.cycles().map(function(t){return{order:t.order(),name:t.name()}}).sort(function(t,n){return t.order===n.order?0:t.order';Object.keys(t).forEach(function(n){e+=''+n+"",t[n].forEach(function(t){e+=""+t.number()+""+t.name()+""+t.description()+""})}),e+="",r.innerHTML=e},e},tr.models.Blip=function(t,n,r,e){var a,u;return a={},u=-1,a.name=function(){return t},a.description=function(){return e||""},a.isNew=function(){return r},a.cycle=function(){return n},a.number=function(){return u},a.setNumber=function(t){u=t},a},tr.models.Cycle=function(t,n){var r={};return r.name=function(){return t},r.order=function(){return n},r},tr.models.Quadrant=function(t){var n,r;return n={},r=[],n.name=function(){return t},n.add=function(t){Array.isArray(t)?r=r.concat(t):r.push(t)},n.blips=function(){return r.slice(0)},n},tr.models.Radar=function(){function t(t){t.forEach(function(t){t.setNumber(++u)})}function n(){var t=[];for(var n in a)a.hasOwnProperty(n)&&null!=a[n]&&t.push(a[n]);return t}function r(){return n().reduce(function(t,n){return t.concat(n.blips())},[])}var e,a,u;return u=0,a={I:null,II:null,III:null,IV:null},e={},e.setFirstQuadrant=function(n){a.I=n,t(a.I.blips())},e.setSecondQuadrant=function(n){a.II=n,t(a.II.blips())},e.setThirdQuadrant=function(n){a.III=n,t(a.III.blips())},e.setFourthQuadrant=function(n){a.IV=n,t(a.IV.blips())},e.hasQuadrants=function(){return!!(a.I||a.II||a.III||a.IV)},e.cycles=function(){var t,n;n=[],t={},r().forEach(function(n){t[n.cycle().name()]=n.cycle()});for(var e in t)t.hasOwnProperty(e)&&n.push(t[e]);return n.slice(0).sort(function(t,n){return t.order()-n.order()})},e.quadrants=function(){return a},e},tr.util.Fib=function(){var t={};return t.sequence=function(t){for(var n=[0,1],r=2;t>r;r++)n[r]=n[r-2]+n[r-1];return n},t.sum=function(n){return 0===n?0:1===n?1:t.sequence(n+1).reduce(function(t,n){return t+n},0)},t}; \ No newline at end of file +var tr=tr||{};tr.models={},tr.graphing={},tr.util={},tr.graphing.Radar=function(t,n){function r(){return Math.round(t/2)}function e(){h.append("line").attr("x1",r()).attr("y1",0).attr("x2",r()).attr("y2",t).attr("stroke-width",14),h.append("line").attr("x1",0).attr("y1",r()).attr("x2",t).attr("y2",r()).attr("stroke-width",14)}function a(t,n){var e=(l.sequence(t.length),l.sum(t.length)),a=l.sum(n);return r()-r()*a/e}function u(t){t.forEach(function(n,e){h.append("circle").attr("cx",r()).attr("cy",r()).attr("r",a(t,e))})}function c(t){var n;n=Math.round(r()/t.length),t.forEach(function(n,e){h.append("text").attr("class","line-text").attr("y",r()+4).attr("x",r()-a(t,e)+10).text(n.name()),h.append("text").attr("class","line-text").attr("y",r()+4).attr("x",r()+a(t,e)-10).attr("text-anchor","end").text(n.name())})}function o(t,n,r){var e,a,u,c,o,i;return e=13,a=n-e,u=t-e+1,c=t+e+1,o=n+e-e/2.5,i=t+1+","+a+" "+u+","+o+" "+c+","+o,h.append("polygon").attr("points",i).attr("class",r).attr("stroke-width",1.5)}function i(t,n,r){h.append("circle").attr("cx",t).attr("cy",n).attr("class",r).attr("stroke-width",1.5).attr("r",10)}function s(t,n,e,u,c){var s;s=n.blips(),t.forEach(function(n,f){var d,l,p;d=a(t,f),l=f==t.length-1?0:a(t,f+1);var p=s.filter(function(t){return t.cycle()==n});p.forEach(function(t){var a,s,f=t.name().split(""),p=f.reduce(function(t,n){return t+n.charCodeAt(0)},0);chance=new Chance(p*n.name().length*t.number()),a=Math.PI*chance.integer({min:13,max:85})/180,s=chance.floating({min:l+25,max:d-10});var I=r()+s*Math.cos(a)*e,m=r()+s*Math.sin(a)*u;t.isNew()?o(I,m,c):i(I,m,c),h.append("text").attr("x",I).attr("y",m+4).attr("class","blip-text").attr("text-anchor","middle").text(t.number())})})}function f(n){function r(t,n,r,e,a){h.append("text").attr("x",r).attr("y",e).attr("class",a).attr("text-anchor",n).text(t)}r(n.I.name(),"end",t-10,10,"first"),r(n.II.name(),"start",10,10,"second"),r(n.III.name(),"start",10,t-10,"third"),r(n.IV.name(),"end",t-10,t-10,"fourth")}var d,l,h;return l=new tr.util.Fib,d={},d.svg=function(){return h},d.init=function(t){return h=d3.select(t||"body").append("svg"),d},d.plot=function(){var r,a;r=n.cycles().reverse(),a=n.quadrants(),h.attr("width",t).attr("height",t),u(r),e(),c(r),n.hasQuadrants()&&(f(a),s(r,a.I,1,-1,"first"),s(r,a.II,-1,-1,"second"),s(r,a.III,-1,1,"third"),s(r,a.IV,1,1,"fourth"))},d},tr.graphing.RefTable=function(t){function n(){var n={};t.cycles().map(function(t){return{order:t.order(),name:t.name()}}).sort(function(t,n){return t.order===n.order?0:t.order';Object.keys(t).forEach(function(n){e+=''+n+"",t[n].forEach(function(t){e+=""+t.number()+""+t.name()+""+t.description()+""})}),e+="",r.innerHTML=e},e},tr.models.Blip=function(t,n,r,e){var a,u;return a={},u=-1,a.name=function(){return t},a.description=function(){return e||""},a.isNew=function(){return r},a.cycle=function(){return n},a.number=function(){return u},a.setNumber=function(t){u=t},a},tr.models.Cycle=function(t,n){var r={};return r.name=function(){return t},r.order=function(){return n},r},tr.models.Quadrant=function(t){var n,r;return n={},r=[],n.name=function(){return t},n.add=function(t){Array.isArray(t)?r=r.concat(t):r.push(t)},n.blips=function(){return r.slice(0)},n},tr.models.Radar=function(){function t(t){t.forEach(function(t){t.setNumber(++u)})}function n(){var t=[];for(var n in a)a.hasOwnProperty(n)&&null!=a[n]&&t.push(a[n]);return t}function r(){return n().reduce(function(t,n){return t.concat(n.blips())},[])}var e,a,u;return u=0,a={I:null,II:null,III:null,IV:null},e={},e.setFirstQuadrant=function(n){a.I=n,t(a.I.blips())},e.setSecondQuadrant=function(n){a.II=n,t(a.II.blips())},e.setThirdQuadrant=function(n){a.III=n,t(a.III.blips())},e.setFourthQuadrant=function(n){a.IV=n,t(a.IV.blips())},e.hasQuadrants=function(){return!!(a.I||a.II||a.III||a.IV)},e.cycles=function(){var t,n;n=[],t={},r().forEach(function(n){t[n.cycle().name()]=n.cycle()});for(var e in t)t.hasOwnProperty(e)&&n.push(t[e]);return n.slice(0).sort(function(t,n){return t.order()-n.order()})},e.quadrants=function(){return a},e},tr.util.Fib=function(){var t={};return t.sequence=function(t){for(var n=[0,1],r=2;t>r;r++)n[r]=n[r-2]+n[r-1];return n},t.sum=function(n){return 0===n?0:1===n?1:t.sequence(n+1).reduce(function(t,n){return t+n},0)},t}; +//# sourceMappingURL=./tech-radar.min.js.map \ No newline at end of file diff --git a/examples/tech-radar.min.js.map b/examples/tech-radar.min.js.map index b8146eb..9971abb 100644 --- a/examples/tech-radar.min.js.map +++ b/examples/tech-radar.min.js.map @@ -1,5 +1 @@ -/** - * tech-radar - * @version v0.1.6 - */ -{"version":3,"file":"tech-radar.min.js.map","sources":["tech-radar.min.js"],"names":["tr","models","graphing","util","Radar","size","radar","center","Math","round","plotLines","svg","append","attr","getRadius","cycles","i","total","fib","sequence","length","sum","plotCircles","forEach","cycle","plotTexts","increment","text","name","triangle","x","y","cssClass","tsize","top","left","right","bottom","points","circle","plotBlips","quadrant","adjustX","adjustY","blips","maxRadius","minRadius","cycleBlips","filter","blip","angleInRad","radius","split","reduce","p","c","charCodeAt","chance","Chance","number","PI","integer","min","max","floating","cos","sin","isNew","plotQuadrantNames","quadrants","plotName","anchor","I","II","III","IV","self","Fib","init","selector","d3","select","plot","reverse","hasQuadrants","RefTable","blipsByCycle","map","order","sort","a","b","Object","keys","concat","push","injectionElement","document","querySelector","render","html","description","innerHTML","Blip","setNumber","newNumber","Cycle","Quadrant","add","newBlips","Array","isArray","slice","setNumbers","blipNumber","allQuadrants","all","hasOwnProperty","allBlips","setFirstQuadrant","setSecondQuadrant","setThirdQuadrant","setFourthQuadrant","cycleHash","cycleArray","result","previous","current"],"mappings":"AAAA,GAAIA,IAAKA,MACTA,IAAGC,UACHD,GAAGE,YACHF,GAAGG,QAEHH,GAAGE,SAASE,MAAQ,SAAUC,EAAMC,GAUlC,QAASC,KACP,MAAOC,MAAKC,MAAMJ,EAAK,GAGzB,QAASK,KACPC,EAAIC,O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EAAUM,GAAG/B,UAqB1BgC,EAAKQ,aAAe,WAClB,SAASf,EAAUG,GAAOH,EAAUI,IAAQJ,EAAUK,KAASL,EAAUM,KAG3EC,EAAK7D,OAAS,WACZ,GAAI4G,GAAWC,CAEfA,MACAD,KAEAL,IAAW/F,QAAQ,SAAU0B,GAC3B0E,EAAU1E,EAAKzB,QAAQI,QAAUqB,EAAKzB,SAGxC,KAAK,GAAI8B,KAAKqE,GACRA,EAAUN,eAAe/D,IAC3BsE,EAAW7B,KAAK4B,EAAUrE,GAI9B,OAAOsE,GAAWZ,MAAM,GAAGvB,KAAK,SAAUC,EAAGC,GAAK,MAAOD,GAAEF,QAAUG,EAAEH,WAGzEZ,EAAKP,UAAY,WACf,MAAOA,IAGFO,GAGT5E,GAAGG,KAAK0E,IAAM,WACZ,GAAID,KAqBJ,OAnBAA,GAAKzD,SAAW,SAAUC,GAGxB,IAAK,GAFDyG,IAAU,EAAG,GAER7G,EAAI,EAAOI,EAAJJ,EAAYA,IAC1B6G,EAAO7G,GAAK6G,EAAO7G,EAAE,GAAK6G,EAAO7G,EAAE,EAGrC,OAAO6G,IAGTjD,EAAKvD,IAAM,SAAUD,GACnB,MAAe,KAAXA,EAAuB,EACZ,IAAXA,EAAuB,EAEpBwD,EAAKzD,SAASC,EAAS,GAAGiC,OAAO,SAAUyE,EAAUC,GAC1D,MAAOD,GAAWC,GACjB,IAGEnD"} \ No newline at end of file +{"version":3,"file":"./dist/tech-radar.min.js","sources":["./src/namespaces.js","./src/graphing/radar.js","./src/graphing/ref-table.js","./src/models/blip.js","./src/models/cycle.js","./src/models/quadrant.js","./src/models/radar.js","./src/util/fib.js"],"names":["tr","models","graphing","util","Radar","size","radar","center","Math","round","plotLines","svg","append","attr","getRadius","cycles","i","total","fib","sequence","length","sum","plotCircles","forEach","cycle","plotTexts","increment","text","name","triangle","x","y","cssClass","tsize","top","left","right","bottom","points","circle","plotBlips","quadrant","adjustX","adjustY","blips","maxRadius","minRadius","cycleBlips","filter","blip","angleInRad","radius","split","reduce","p","c","charCodeAt","chance","Chance","number","PI","integer","min","max","floating","cos","sin","isNew","plotQuadrantNames","quadrants","plotName","anchor","I","II","III","IV","self","Fib","init","selector","d3","select","plot","reverse","hasQuadrants","RefTable","blipsByCycle","map","order","sort","a","b","Object","keys","concat","push","injectionElement","document","querySelector","render","html","description","innerHTML","Blip","setNumber","newNumber","Cycle","Quadrant","add","newBlips","Array","isArray","slice","setNumbers","blipNumber","allQuadrants","all","hasOwnProperty","allBlips","setFirstQuadrant","setSecondQuadrant","setThirdQuadrant","setFourthQuadrant","cycleHash","cycleArray","result","previous","current"],"mappings":"AAAA,GAAIA,IAAKA,MACTA,IAAGC,UACHD,GAAGE,YACHF,GAAGG,QCHHH,GAAGE,SAASE,MAAQ,SAAUC,EAAMC,GAUlC,QAASC,KACP,MAAOC,MAAKC,MAAMJ,EAAK,GAGzB,QAASK,KACPC,EAAIC,OAAO,QACRC,KAAK,KAAMN,KACXM,KAAK,KAAM,GACXA,KAAK,KAAMN,KACXM,KAAK,KAAMR,GACXQ,KAAK,eAAgB,IAExBF,EAAIC,OAAO,QACRC,KAAK,KAAM,GACXA,KAAK,KAAMN,KACXM,KAAK,KAAMR,GACXQ,KAAK,KAAMN,KACXM,KAAK,eAAgB,IAG1B,QAASC,GAAUC,EAAQC,GACzB,GACIC,IADWC,EAAIC,SAASJ,EAAOK,QACvBF,EAAIG,IAAIN,EAAOK,SACvBC,EAAMH,EAAIG,IAAIL,EAElB,OAAOT,KAAYA,IAAWc,EAAMJ,EAGtC,QAASK,GAAYP,GAGnBA,EAAOQ,QAAQ,SAAUC,EAAOR,GAC9BL,EAAIC,OAAO,UACRC,KAAK,KAAMN,KACXM,KAAK,KAAMN,KACXM,KAAK,IAAKC,EAAUC,EAAQC,MAInC,QAASS,GAAUV,GACjB,GAAIW,EAEJA,GAAYlB,KAAKC,MAAMF,IAAWQ,EAAOK,QAEzCL,EAAOQ,QAAQ,SAAUC,EAAOR,GAC9BL,EAAI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GAAK6G,EAAO7G,EAAE,EAGrC,OAAO6G,IAGTjD,EAAKvD,IAAM,SAAUD,GACnB,MAAe,KAAXA,EAAuB,EACZ,IAAXA,EAAuB,EAEpBwD,EAAKzD,SAASC,EAAS,GAAGiC,OAAO,SAAUyE,EAAUC,GAC1D,MAAOD,GAAWC,GACjB,IAGEnD"} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js deleted file mode 100644 index 509a730..0000000 --- a/gulpfile.js +++ /dev/null @@ -1,98 +0,0 @@ -var gulp = require('gulp') - , pkg = require('./package.json') - , gutil = require('gulp-util') - , gkarma = require('gulp-karma') - , sass = require('gulp-sass') - , concat = require('gulp-concat') - , uglify = require('gulp-uglify') - , clean = require('gulp-clean') - , header = require('gulp-header') - , files - , paths; - - -banner = [ - '/**', - ' * <%= pkg.name %>', - ' * @version v<%= pkg.version %>', - ' */', - '' -].join('\n'); - -paths = { - DEPS: ['bower_components/chance/chance.js', 'bower_components/d3/d3.min.js'] -}; - -files = { - LIB: 'bower_components/d3/*.min.js', - NS: 'src/namespaces.js', - SOURCE: 'src/**/*.js', - SPEC: 'test/**/*-spec.js', - STYLESHEETS: 'src/stylesheets/**/*.scss' -}; - -gulp.task('sass', function () { - gulp.src(files.STYLESHEETS) - .pipe(sass()) - .pipe(gulp.dest('./dist/')); -}); - -gulp.task('concat', function () { - gulp.src([files.NS, files.SOURCE]) - .pipe(concat('tech-radar.js')) - .pipe(header(banner, { pkg: pkg })) - .pipe(gulp.dest('./dist/')); -}); -var clean = require('gulp-clean'); - -gulp.task('clean', function() { - gulp.src('./dist/', {read: false}) - .pipe(clean({force: true})); -}); - -gulp.task('compress', function() { - gulp.src([files.NS, files.SOURCE]) - .pipe(concat('tech-radar.min.js')) - .pipe(uglify({outSourceMap: true})) - .pipe(header(banner, { pkg: pkg })) - .pipe(gulp.dest('./dist/')) -}); - -gulp.task('deps', function () { - gulp.src(paths.DEPS.concat('./dist/**/*.*')) - .pipe(gulp.dest('./examples')); -}); - -gulp.task('dist', ['clean', 'concat', 'compress', 'sass']); -gulp.task('examples', ['clean', 'concat', 'compress', 'sass', 'deps']); - -gulp.task('gh-pages', function () { - var ghpages = require('gh-pages') - , path = require('path') - , options = {}; - - options.logger = console.log.bind(this); - - function callback(err) { - if (err) { - console.error('Error publishing to gh-pages', err); - } else { - console.log('Successfully published to gh-pages'); - } - } - - ghpages.publish(path.join(__dirname, './examples'), options, callback); -}); - -gulp.task('test', function (){ - var karma; - - karma = gkarma({ - configFile: 'karma.conf.js', - action: 'run' - }); - - return gulp.src( - [files.LIB, files.NS, files.SOURCE, files.SPEC] - ).pipe(karma); -}); diff --git a/karma-dist.conf.js b/karma-dist.conf.js new file mode 100644 index 0000000..57cc7bc --- /dev/null +++ b/karma-dist.conf.js @@ -0,0 +1,24 @@ +// Karma configuration +// Generated on Wed May 20 2015 15:45:04 GMT-0300 (BRT) + +module.exports = function(config) { + config.set({ + basePath: '.', + frameworks: ['jasmine'], + files: [ + 'dist/chance.js', + 'dist/d3.min.js', + 'dist/tech-radar.min.js', + 'test/**/*.js' + ], + exclude: [ ], + reporters: ['progress'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: false, + browsers: ['PhantomJS'], + captureTimeout: 60000, + singleRun: false + }); +}; diff --git a/karma.conf.js b/karma.conf.js index 1753663..070f89e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -1,6 +1,27 @@ +// Karma configuration +// Generated on Wed May 20 2015 15:45:04 GMT-0300 (BRT) + module.exports = function(config) { config.set({ + basePath: '.', frameworks: ['jasmine'], - browsers: ['PhantomJS'] + files: [ + 'bower_components/chance/chance.js', + 'bower_components/d3/d3.min.js', + 'src/namespaces.js', + 'src/util/**/*.js', + 'src/models/**/*.js', + 'src/graphing/**/*.js', + 'test/**/*.js' + ], + exclude: [ ], + reporters: ['progress'], + port: 9876, + colors: true, + logLevel: config.LOG_INFO, + autoWatch: false, + browsers: ['PhantomJS'], + captureTimeout: 60000, + singleRun: false }); }; diff --git a/package.json b/package.json index f48377f..02826bc 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,17 @@ "description": "", "main": "index.js", "scripts": { - "test": "gulp test", + "test": "karma start karma.conf.js --single-run", + "test:dist": "npm run build && karma start karma-dist.conf.js --single-run", + "build:clean": "rm -rf ./dist/*", + "build:sass": "node-sass -r ./src/stylesheets/base.scss ./dist/base.css", + "build:uglify": "uglifyjs -c -m -o ./dist/tech-radar.min.js --source-map ./dist/tech-radar.min.js.map --source-map-url ./tech-radar.min.js.map -- ./src/namespaces.js ./src/**/*.js", + "build:deps": "cp ./bower_components/**/{chance,d3.min}*.js ./dist/", + "build": "npm run build:clean && npm run build:sass && npm run build:uglify && npm run build:deps", + "examples:clean": "rm -rf ./examples/*{.js,.css,.map}", + "examples:deps": "cp -r ./dist/* ./examples/", + "examples": "npm run build && npm run examples:clean && npm run examples:deps", + "publishExamples": "node ./scripts/publish-examples.js", "postinstall": "bower install" }, "author": "Bruno Trecenti", @@ -17,25 +27,14 @@ ], "license": "ISC", "devDependencies": { - "gulp-util": "~2.2.14", - "gulp": "~3.5.2", "karma-script-launcher": "~0.1.0", - "karma-chrome-launcher": "~0.1.2", - "karma-firefox-launcher": "~0.1.3", - "karma-html2js-preprocessor": "~0.1.0", "karma-jasmine": "~0.1.5", - "karma-coffee-preprocessor": "~0.1.3", "requirejs": "~2.1.11", - "karma-requirejs": "~0.2.1", "karma-phantomjs-launcher": "~0.1.2", "karma": "~0.10.9", - "gulp-karma": "0.0.2", - "gulp-sass": "~0.7.1", - "gulp-concat": "~2.2.0", - "gulp-uglify": "~0.2.1", - "gulp-clean": "~0.2.4", - "gulp-header": "~1.0.2", - "bower": "^1.3.3" + "bower": "^1.3.3", + "node-sass": "^3.1.1", + "uglify-js": "^2.4.23" }, "dependencies": {} } diff --git a/scripts/publish-examples.js b/scripts/publish-examples.js new file mode 100644 index 0000000..42dca3d --- /dev/null +++ b/scripts/publish-examples.js @@ -0,0 +1,15 @@ +var ghpages = require('gh-pages') + , path = require('path') + , options = {}; + +options.logger = console.log.bind(this); + +function callback(err) { + if (err) { + console.error('Error publishing to gh-pages', err); + } else { + console.log('Successfully published to gh-pages'); + } +} + +ghpages.publish(path.join(__dirname, './examples'), options, callback); -- 2.39.2