SB-6.1-PRE

This commit is contained in:
ItzEmerald committed 2021-02-02 13:50:53 +00:00
1 parent 690169a409
commit 358a25f522
3760 files changed
+300059 -36

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
{
"directory": "test/lib"
}
+4
View File
@@ -0,0 +1,4 @@
node_modules/
docs/
test/
dist/
+280
View File
@@ -0,0 +1,280 @@
module.exports = {
"env": {
"browser": true,
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"globals": {
"Atomics": "readonly",
"SharedArrayBuffer": "readonly",
"define": "writable",
"chance": "writable"
},
"parserOptions": {
"ecmaVersion": 2018
},
"rules": {
"accessor-pairs": "error",
"array-bracket-newline": "off",
"array-bracket-spacing": "off",
"array-callback-return": "error",
"array-element-newline": "off",
"arrow-body-style": "error",
"arrow-parens": "error",
"arrow-spacing": "error",
"block-scoped-var": "off",
"block-spacing": "off",
"brace-style": "off",
"callback-return": "error",
"camelcase": "off",
"capitalized-comments": "off",
"class-methods-use-this": "error",
"comma-dangle": "off",
"comma-spacing": "off",
"comma-style": [
"error",
"last"
],
"complexity": "off",
"computed-property-spacing": [
"error",
"never"
],
"consistent-return": "off",
"consistent-this": "off",
"curly": "error",
"default-case": "off",
"dot-location": [
"error",
"property"
],
"dot-notation": "error",
"eol-last": "error",
"eqeqeq": "error",
"func-call-spacing": "off",
"func-name-matching": "error",
"func-names": "off",
"func-style": "off",
"function-call-argument-newline": [
"error",
"consistent"
],
"function-paren-newline": "error",
"generator-star-spacing": "error",
"global-require": "error",
"guard-for-in": "off",
"handle-callback-err": "error",
"id-blacklist": "error",
"id-length": "off",
"id-match": "error",
"implicit-arrow-linebreak": "error",
"indent": "off",
"indent-legacy": "off",
"init-declarations": "off",
"jsx-quotes": "error",
"key-spacing": "off",
"keyword-spacing": "off",
"line-comment-position": "off",
"linebreak-style": [
"error",
"unix"
],
"lines-around-comment": "off",
"lines-around-directive": "error",
"lines-between-class-members": "error",
"max-classes-per-file": "error",
"max-depth": "error",
"max-len": "off",
"max-lines": "off",
"max-lines-per-function": "off",
"max-nested-callbacks": "error",
"max-params": "off",
"max-statements": "off",
"max-statements-per-line": "off",
"multiline-comment-style": "off",
"multiline-ternary": [
"error",
"always-multiline"
],
"new-cap": "error",
"new-parens": "error",
"newline-after-var": "off",
"newline-before-return": "off",
"newline-per-chained-call": "off",
"no-alert": "error",
"no-array-constructor": "off",
"no-await-in-loop": "error",
"no-bitwise": "off",
"no-buffer-constructor": "off",
"no-caller": "error",
"no-catch-shadow": "error",
"no-confusing-arrow": "error",
"no-console": "error",
"no-continue": "error",
"no-div-regex": "error",
"no-duplicate-imports": "error",
"no-else-return": "off",
"no-empty-function": "off",
"no-eq-null": "error",
"no-eval": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-extra-boolean-cast": "off",
"no-extra-label": "error",
"no-extra-parens": "off",
"no-floating-decimal": "error",
"no-implicit-coercion": [
"error",
{
"boolean": false,
"number": false,
"string": false
}
],
"no-implicit-globals": "off",
"no-implied-eval": "error",
"no-inline-comments": "off",
"no-inner-declarations": [
"error",
"functions"
],
"no-invalid-this": "error",
"no-iterator": "error",
"no-label-var": "error",
"no-labels": "error",
"no-lone-blocks": "error",
"no-lonely-if": "off",
"no-loop-func": "error",
"no-magic-numbers": "off",
"no-mixed-operators": "off",
"no-mixed-requires": "error",
"no-multi-assign": "off",
"no-multi-spaces": "off",
"no-multi-str": "error",
"no-multiple-empty-lines": "error",
"no-native-reassign": "error",
"no-negated-condition": "off",
"no-negated-in-lhs": "error",
"no-nested-ternary": "off",
"no-new": "error",
"no-new-func": "error",
"no-new-object": "error",
"no-new-require": "error",
"no-new-wrappers": "error",
"no-octal-escape": "error",
"no-param-reassign": "off",
"no-path-concat": "error",
"no-plusplus": "off",
"no-process-env": "error",
"no-process-exit": "error",
"no-proto": "error",
"no-restricted-globals": "error",
"no-restricted-imports": "error",
"no-restricted-modules": "error",
"no-restricted-properties": "error",
"no-restricted-syntax": "error",
"no-return-assign": "error",
"no-return-await": "error",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-spaced-func": "off",
"no-sync": "error",
"no-tabs": [
"error",
{
"allowIndentationTabs": true
}
],
"no-template-curly-in-string": "error",
"no-ternary": "off",
"no-throw-literal": "error",
"no-trailing-spaces": "error",
"no-undef-init": "error",
"no-undefined": "off",
"no-underscore-dangle": "off",
"no-unmodified-loop-condition": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-use-before-define": "off",
"no-useless-call": "error",
"no-useless-computed-key": "error",
"no-useless-concat": "error",
"no-useless-constructor": "error",
"no-useless-rename": "error",
"no-useless-return": "error",
"no-var": "off",
"no-void": "error",
"no-warning-comments": "off",
"no-whitespace-before-property": "error",
"nonblock-statement-body-position": "error",
"object-curly-newline": "error",
"object-curly-spacing": "off",
"object-shorthand": "off",
"one-var": "off",
"one-var-declaration-per-line": "off",
"operator-assignment": "off",
"operator-linebreak": [
"error",
"after"
],
"padded-blocks": "off",
"padding-line-between-statements": "error",
"prefer-arrow-callback": "off",
"prefer-const": "error",
"prefer-destructuring": "off",
"prefer-named-capture-group": "error",
"prefer-numeric-literals": "error",
"prefer-object-spread": "error",
"prefer-promise-reject-errors": "error",
"prefer-reflect": "off",
"prefer-rest-params": "off",
"prefer-spread": "off",
"prefer-template": "off",
"quote-props": "off",
"quotes": "off",
"radix": "off",
"require-await": "error",
"require-jsdoc": "off",
"require-unicode-regexp": "off",
"rest-spread-spacing": "error",
"semi": "off",
"semi-spacing": "off",
"semi-style": "off",
"sort-imports": "error",
"sort-keys": "off",
"sort-vars": "off",
"space-before-blocks": "off",
"space-before-function-paren": "off",
"space-in-parens": "off",
"space-infix-ops": "off",
"space-unary-ops": "error",
"spaced-comment": "off",
"strict": [
"error",
"never"
],
"switch-colon-spacing": "error",
"symbol-description": "error",
"template-curly-spacing": "error",
"template-tag-spacing": "error",
"unicode-bom": [
"error",
"never"
],
"valid-jsdoc": "off",
"vars-on-top": "off",
"wrap-iife": [
"error",
"any"
],
"wrap-regex": "off",
"yield-star-spacing": "error",
"yoda": [
"error",
"never"
]
}
};
+12
View File
@@ -0,0 +1,12 @@
# These are supported funding model platforms
github: [victorquinn] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
+24
View File
@@ -0,0 +1,24 @@
name: Code Coverage
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Use Node.js 10.x
uses: actions/setup-node@v1
with:
node-version: 10.x
- name: install and coverage
run: |
yarn
yarn coverage
env:
CI: true
- name: Coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.github_token }}
+34
View File
@@ -0,0 +1,34 @@
name: Documentation
on:
pull_request:
branches:
- master
paths:
- 'docs/**/*'
push:
branches:
- master
paths:
- 'docs/**/*'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- name: build and deploy
if: github.event_name == 'pull_request' && github.event.pull_request.merged == 'true'
run: |
yarn
yarn docs
yarn docs:publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPO: chancejs/chancejs
GIT_NAME: Travis CI
GIT_EMAIL: mail@victorquinn.ocm
GIT_SOURCE: _docpress
+19
View File
@@ -0,0 +1,19 @@
name: Lint
on: [push, pull_request]
jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions/setup-node@v1
with:
node-version: 12
- run: yarn --frozen-lockfile --ignore-engines --ignore-optional --no-bin-links --non-interactive --silent --ignore-scripts --production=false
- name: ESLint Action
uses: gimenete/eslint-action@1.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+53
View File
@@ -0,0 +1,53 @@
name: NPM Publish Package
on:
pull_request:
branches:
- master
push:
branches:
- master
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
- name: install and test
run: |
yarn
yarn run test
publish-npm:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: 12
registry-url: https://registry.npmjs.org/
- name: Publish to NPM
if: github.event_name == 'pull_request' && github.event.pull_request.merged == 'true'
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Commented out until we have access to the Github Package Registry
#
# publish-gpr:
# needs: build
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v1
# - uses: actions/setup-node@v1
# with:
# node-version: 12
# registry-url: https://npm.pkg.github.com/
# scope: '@victorquinn'
# - run: npm publish
# env:
# NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+23
View File
@@ -0,0 +1,23 @@
name: Unit Tests
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [8.x, 10.x, 12.x]
steps:
- uses: actions/checkout@v1
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: yarn install and test
run: |
yarn
yarn run test
env:
CI: true
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) 2015 Victor Quinn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+59
View File
@@ -0,0 +1,59 @@
# Chance
[![Chance Logo](http://chancejs.com/logo.png)](http://chancejs.com)
[![Build Status](https://travis-ci.org/chancejs/chancejs.svg?branch=develop)](https://travis-ci.org/chancejs/chancejs) [![GitHub license](https://img.shields.io/github/license/chancejs/chancejs.svg)](https://github.com/chancejs/chancejs) [![GitHub stars](https://img.shields.io/github/stars/chancejs/chancejs.svg)](https://github.com/chancejs/chancejs) [![npm](https://img.shields.io/npm/dm/chance.svg)](https://npmjs.com/package/chance) [![jsDelivr Hits](https://data.jsdelivr.com/v1/package/npm/chance/badge?style=rounded)](https://www.jsdelivr.com/package/npm/chance) [![npm](https://img.shields.io/npm/v/chance.svg)](https://npmjs.com/package/chance) [![Coverage Status](https://coveralls.io/repos/chancejs/chancejs/badge.svg?branch=master)](https://coveralls.io/r/chancejs/chancejs?branch=master) [![awesomeness](https://img.shields.io/badge/awesomeness-maximum-red.svg)](https://github.com/chancejs/chancejs)
Chance - Random generator helper for JavaScript
Homepage: [http://chancejs.com](http://chancejs.com)
Many more details on [http://chancejs.com](http://chancejs.com) but this single
library can generate random numbers, characters, strings, names, addresses,
dice, and pretty much anything else.
It includes the basic building blocks for all these items and is built on top
of a Mersenne Twister so it can generate these things with repeatability, if
desired.
## Usage
See the [full docs](https://chancejs.com) for details on installation and usage.
## Dependent tools
* [Chance CLI](https://github.com/chancejs/chance-cli) - Use Chance on the command line.
* [Chance Token Replacer](https://github.com/drewbrokke/chance-token-replacer) - Replace tokens in a string with Chance generated items.
* [Dream.js](https://github.com/adleroliveira/dreamjs) - Lightweight json data generator
* [Fake JSON Schema](https://github.com/pateketrueke/json-schema-faker/) - Use chance generators to populate JSON Schema samples.
* [Mocker Data Generator](https://github.com/danibram/mocker-data-generator/) - Minimal JSON data generator.
* [swagger-mock-api](https://github.com/dzdrazil/swagger-mock-api/) - Generate API mocks from a Swagger spec file enriched with Chance types and constraints
* [fony](https://github.com/captainsafia/fony) - A simple command line tool for generating fake data from a template string
Or [view all of the dependents on npm](https://www.npmjs.com/package/chance)
*Know a library that uses Chance that isn't here? Update the README and submit a PR!*
## Author
### Victor Quinn
[https://www.victorquinn.com](https://www.victorquinn.com)
[@victorquinn](https://twitter.com/victorquinn)
Please feel free to reach out to me if you have any questions or suggestions.
### Contributors
THANK YOU!
### Contribute!
Be a part of this project! You can run the test using the following.
1. Install dependencies from package.json by running `npm install`
2. Run the test via `npm test`
3. Make some fun new modules!
This project is licensed under the [MIT License](http://en.wikipedia.org/wiki/MIT_License) so feel free to hack away :)
Proudly written in Washington, D.C.
+22
View File
@@ -0,0 +1,22 @@
{
"name": "chance",
"version": "1.1.7",
"main": "chance.js",
"ignore": [
"node_modules"
],
"description": "Chance - Utility library to generate anything random",
"homepage": "http://chancejs.com",
"keywords": [
"chance",
"random",
"generator"
],
"author": {
"name": "Victor Quinn",
"web": "https://www.victorquinn.com"
},
"devDependencies": {
"phone_number_js": "~1.0.0"
}
}
+7813
View File
File diff suppressed because it is too large. Load diff
+2
View File
@@ -0,0 +1,2 @@
!function(){function a(e){if(!(this instanceof a))return e||(e=null),null===e?new a:new a(e);if("function"==typeof e)return this.random=e,this;arguments.length&&(this.seed=0);for(var n=0;n<arguments.length;n++){var i=0;if("[object String]"===Object.prototype.toString.call(arguments[n]))for(var r=0;r<arguments[n].length;r++){for(var o=0,t=0;t<arguments[n].length;t++)o=arguments[n].charCodeAt(t)+(o<<6)+(o<<16)-o;i+=o}else i=arguments[n];this.seed+=(arguments.length-n)*i}return this.mt=this.mersenne_twister(this.seed),this.bimd5=this.blueimp_md5(),this.random=function(){return this.mt.random(this.seed)},this}function e(a,e){if(a=a||{},e)for(var n in e)void 0===a[n]&&(a[n]=e[n]);return a}function n(a,e){if(a)throw new RangeError(e)}function i(a){return function(){return this.natural(a)}}function r(a,e){for(var n,i=p(a),r=0,o=i.length;r<o;r++)e[n=i[r]]=a[n]||e[n]}function o(a,e){for(var n=0,i=a.length;n<i;n++)e[n]=a[n]}function t(a,e){var n=Array.isArray(a),i=e||(n?new Array(a.length):{});return n?o(a,i):r(a,i),i}var s=9007199254740992,l="abcdefghijklmnopqrstuvwxyz",c=l.toUpperCase(),m="0123456789abcdef",u=Array.prototype.slice;a.prototype.VERSION="1.0.13";var d=function(){throw new Error("No Base64 encoder available.")};"function"==typeof btoa?d=btoa:"function"==typeof Buffer&&(d=function(a){return new Buffer(a).toString("base64")}),a.prototype.bool=function(a){return a=e(a,{likelihood:50}),n(a.likelihood<0||a.likelihood>100,"Chance: Likelihood accepts values from 0 to 100."),100*this.random()<a.likelihood},a.prototype.animal=function(a){return void 0!==(a=e(a)).type?(n(!this.get("animals")[a.type.toLowerCase()],"Please pick from desert, ocean, grassland, forest, zoo, pets, farm."),this.pick(this.get("animals")[a.type.toLowerCase()])):(animalTypeArray=["desert","forest","ocean","zoo","farm","pet","grassland"],this.pick(this.get("animals")[this.pick(animalTypeArray)]))},a.prototype.character=function(a){n((a=e(a)).alpha&&a.symbols,"Chance: Cannot specify both alpha and symbols.");var i,r;return i="lower"===a.casing?l:"upper"===a.casing?c:l+c,(r=a.pool?a.pool:a.alpha?i:a.symbols?"!@#$%^&*()[]":i+"0123456789!@#$%^&*()[]").charAt(this.natural({max:r.length-1}))},a.prototype.floating=function(a){n((a=e(a,{fixed:4})).fixed&&a.precision,"Chance: Cannot specify both fixed and precision.");var i,r=Math.pow(10,a.fixed),o=s/r,t=-o;n(a.min&&a.fixed&&a.min<t,"Chance: Min specified is out of range with fixed. Min should be, at least, "+t),n(a.max&&a.fixed&&a.max>o,"Chance: Max specified is out of range with fixed. Max should be, at most, "+o),a=e(a,{min:t,max:o});var l=((i=this.integer({min:a.min*r,max:a.max*r}))/r).toFixed(a.fixed);return parseFloat(l)},a.prototype.integer=function(a){return a=e(a,{min:-9007199254740992,max:s}),n(a.min>a.max,"Chance: Min cannot be greater than Max."),Math.floor(this.random()*(a.max-a.min+1)+a.min)},a.prototype.natural=function(a){return"number"==typeof(a=e(a,{min:0,max:s})).numerals&&(n(a.numerals<1,"Chance: Numerals cannot be less than one."),a.min=Math.pow(10,a.numerals-1),a.max=Math.pow(10,a.numerals)-1),n(a.min<0,"Chance: Min cannot be less than zero."),this.integer(a)},a.prototype.hex=function(a){n((a=e(a,{min:0,max:s,casing:"lower"})).min<0,"Chance: Min cannot be less than zero.");var i=this.natural({min:a.min,max:a.max});return"upper"===a.casing?i.toString(16).toUpperCase():i.toString(16)},a.prototype.letter=function(a){a=e(a,{casing:"lower"});var n=this.character({pool:"abcdefghijklmnopqrstuvwxyz"});return"upper"===a.casing&&(n=n.toUpperCase()),n},a.prototype.string=function(a){n((a=e(a,{length:this.natural({min:5,max:20})})).length<0,"Chance: Length cannot be less than zero.");var i=a.length;return this.n(this.character,i,a).join("")},a.prototype.capitalize=function(a){return a.charAt(0).toUpperCase()+a.substr(1)},a.prototype.mixin=function(e){for(var n in e)a.prototype[n]=e[n];return this},a.prototype.unique=function(a,e,i){n("function"!=typeof a,"Chance: The first argument must be a function.");var r=function(a,e){return-1!==a.indexOf(e)};i&&(r=i.comparator||r);for(var o,t=[],s=0,l=50*e,c=u.call(arguments,2);t.length<e;){var m=JSON.parse(JSON.stringify(c));if(o=a.apply(this,m),r(t,o)||(t.push(o),s=0),++s>l)throw new RangeError("Chance: num is likely too large for sample set")}return t},a.prototype.n=function(a,e){n("function"!=typeof a,"Chance: The first argument must be a function."),void 0===e&&(e=1);var i=e,r=[],o=u.call(arguments,2);for(i=Math.max(0,i),null;i--;null)r.push(a.apply(this,o));return r},a.prototype.pad=function(a,e,n){return n=n||"0",(a+="").length>=e?a:new Array(e-a.length+1).join(n)+a},a.prototype.pick=function(a,e){if(0===a.length)throw new RangeError("Chance: Cannot pick() from an empty array");return e&&1!==e?this.shuffle(a).slice(0,e):a[this.natural({max:a.length-1})]},a.prototype.pickone=function(a){if(0===a.length)throw new RangeError("Chance: Cannot pickone() from an empty array");return a[this.natural({max:a.length-1})]},a.prototype.pickset=function(a,Line truncated
//# sourceMappingURL=chance.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"sources":["chance.min.js"],"names":["Chance","seed","this","random","arguments","length","i","seedling","Object","prototype","toString","call","j","hash","k","charCodeAt","mt","mersenne_twister","bimd5","blueimp_md5","initOptions","options","defaults","testRange","test","errorMessage","RangeError","diceFn","range","natural","_copyObject","source","target","key","keys","o_keys","l","_copyArray","copyObject","_target","isArray","Array","MAX_INT","CHARS_LOWER","CHARS_UPPER","toUpperCase","HEX_POOL","NUMBERS","slice","VERSION","base64","Error","btoa","Buffer","input","bool","likelihood","animal","type","get","toLowerCase","pick","animalTypeArray","character","alpha","symbols","letters","pool","casing","charAt","max","floating","fixed","precision","num","Math","pow","min","num_fixed","integer","toFixed","parseFloat","floor","numerals","hex","letter","string","n","join","capitalize","word","substr","mixin","obj","func_name","unique","fn","comparator","arr","val","indexOf","result","count","MAX_DUPLICATES","params","clonedParams","JSON","parse","stringify","apply","push","pad","number","width","shuffle","pickone","pickset","old_array","new_array","Number","splice","weighted","weights","trim","sum","weightIndex","isNaN","chosenIdx","selected","total","lastGoodIdx","chosen","paragraph","sentences","sentence","text","words","punctuation","syllable","chr","consonants","syllables","substring","age","ageRange","birthday","currentYear","Date","getFullYear","setFullYear","year","date","cpf","formatted","d1","d2","replace","cnpj","first","gender","nationality","profession","rank","company","extraGenders","concat","last","israelId","x","y","thisDigit","parseInt","mrz","checkDigit","split","multipliers","runningTotal","forEach","idx","pos","that","passportNumber","dob","getMonth","getDate","expiry","issuer","opts","generate","name","middle","middle_initial","prefix","suffix","name_prefixes","prefixes","abbreviation","name_prefix","full","HIDN","idn","ssn","dash","ssnFour","dashes","name_suffixes","name_suffix","nationalities","android_id","apple_token","wp8_anid2","wp7_anid","guid","bb_pin","avatar","protocol","email","fileExtension","size","fallback","rating","constructor","http","https","g","pg","r","404","mm","identicon","monsterid","wavatar","retro","blank","bmp","gif","jpg","png","md5","color","gray","value","delimiter","rgb","hasAlpha","rgbValue","alphaChannel","min_alpha","max_alpha","min_rgb","max_rgb","min_green","max_green","min_blue","max_blue","start","end","withHash","symbol","hexstring","isGrayscale","format","min_red","max_red","undefined","grayscale","colorValue","domain","tld","fbid","google_analytics","hashtag","ip","ipv6","klout","semver","include_prerelease","prerelease","rpg","tlds","twitter","url","extension","domain_prefix","path","extensions","port","locale","region","locales","address","street","altitude","areacode","parens","city","coordinates","latitude","longitude","countries","country","depth","geohash","geojson","phone","numPick","self","ukNum","parts","section","sections","area","mobile","match","exchange","subscriber","postal","counties","county","provinces","province","state","states","us_states_and_dc","territories","armed_forces","short_suffix","street_suffix","street_suffixes","zip","plusfour","ampm","date_string","american","getTime","m","month","raw","daysInMonth","days","numeric","day","hour","twentyfour","minute","second","millisecond","hammertime","months","timestamp","weekday","weekdays","weekday_only","cc","to_generate","cc_type","luhn_calculate","cc_types","types","short_name","currency_types","currency","timezones","timezone","currency_pair","returnAsString","currencies","reduce","acc","item","code","dollar","cents","euro","toLocaleString","exp","exp_year","exp_month","future","month_int","curMonth","curYear","vat","it_vat","iban","cf","name_generator","isLast","temp","return_value","map","c","date_generator","range1","range2","evens","digit","checkdigit_generator","pl_pesel","controlNumber","pl_nip","pl_regon","note","notes","scales","naturals","flats","sharps","all","flatKey","sharpKey","midi_note","chord_quality","chord_qualities","jazz","chord","tempo","coin","d4","d6","d8","d10","d12","d20","d30","d100","thrown","bits","rolls","p","version","guid_pool","luhn_check","str","digits","reverse","file","fileName","fileOptions","typeRange","extensionObjectCollection","fileType","data","firstNames","male","en","it","nl","female","lastNames","uk","ca","locale_languages","locale_regions","country_regions","us","colorNames","raster","vector","3d","document","abbr","offset","isdst","utc","animals","ocean","desert","grassland","forest","farm","pet","zoo","o_hasOwnProperty","hasOwnProperty","mac_address","separator","networkVersion","normal","mean","dev","normal_pool","s","u","v","norm","sqrt","log","performanceCounter","round","radio","fl","side","set","values","tv","MersenneTwister","BlueImpMD5","N","M","MATRIX_A","UPPER_MASK","LOWER_MASK","mti","init_genrand","init_by_arrLine truncated
+1
View File
@@ -0,0 +1 @@
chancejs.com
+127
View File
@@ -0,0 +1,127 @@
* [Chance](intro.md)
* Usage
* [bower](usage/bower.md)
* [browser](usage/browser.md)
* [cli](usage/cli.md)
* [node](usage/node.md)
* [requirejs](usage/requirejs.md)
* [seed](usage/seed.md)
* [function](usage/function.md)
* Basics
* [bool](basics/bool.md)
* [falsy](basics/falsy.md)
* [character](basics/character.md)
* [floating](basics/floating.md)
* [integer](basics/integer.md)
* [letter](basics/letter.md)
* [natural](basics/natural.md)
* [prime](basics/prime.md)
* [string](basics/string.md)
* [template](basics/template.md)
* Text
* [paragraph](text/paragraph.md)
* [sentence](text/sentence.md)
* [syllable](text/syllable.md)
* [word](text/word.md)
* Person
* [age](person/age.md)
* [birthday](person/birthday.md)
* [cf](person/cf.md)
* [cpf](person/cpf.md)
* [first](person/first.md)
* [gender](person/gender.md)
* [last](person/last.md)
* [name](person/name.md)
* [prefix](person/prefix.md)
* [ssn](person/ssn.md)
* [suffix](person/suffix.md)
* Thing
* [animal](thing/animal.md)
* Mobile
* [android_id](mobile/android_id.md)
* [apple_token](mobile/apple_token.md)
* [bb_pin](mobile/bb_pin.md)
* [wp7_anid](mobile/wp7_anid.md)
* [wp8_anid2](mobile/wp8_anid2.md)
* Web
* [avatar](web/avatar.md)
* [color](web/color.md)
* [company](web/company.md)
* [domain](web/domain.md)
* [email](web/email.md)
* [fbid](web/fbid.md)
* [google_analytics](web/google_analytics.md)
* [hashtag](web/hashtag.md)
* [ip](web/ip.md)
* [ipv6](web/ipv6.md)
* [klout](web/klout.md)
* [profession](web/profession.md)
* [tld](web/tld.md)
* [twitter](web/twitter.md)
* [url](web/url.md)
* Location
* [address](location/address.md)
* [altitude](location/altitude.md)
* [areacode](location/areacode.md)
* [city](location/city.md)
* [coordinates](location/coordinates.md)
* [country](location/country.md)
* [depth](location/depth.md)
* [geohash](location/geohash.md)
* [latitude](location/latitude.md)
* [locale](location/locale.md)
* [longitude](location/longitude.md)
* [phone](location/phone.md)
* [postal](location/postal.md)
* [postcode](location/postcode.md)
* [province](location/province.md)
* [state](location/state.md)
* [street](location/street.md)
* [zip](location/zip.md)
* Time
* [ampm](time/ampm.md)
* [date](time/date.md)
* [hammertime](time/hammertime.md)
* [hour](time/hour.md)
* [millisecond](time/millisecond.md)
* [minute](time/minute.md)
* [month](time/month.md)
* [second](time/second.md)
* [timestamp](time/timestamp.md)
* [timezone](time/timezone.md)
* [weekday](time/weekday.md)
* [year](time/year.md)
* Finance
* [cc](finance/cc.md)
* [cc_type](finance/cc_type.md)
* [currency](finance/currency.md)
* [currency_pair](finance/currency_pair.md)
* [dollar](finance/dollar.md)
* [euro](finance/euro.md)
* [exp](finance/exp.md)
* [exp_month](finance/exp_month.md)
* [exp_year](finance/exp_year.md)
* Helpers
* [capitalize](helpers/capitalize.md)
* [mixin](helpers/mixin.md)
* [pad](helpers/pad.md)
* [pick](helpers/pick.md)
* [pickone](helpers/pickone.md)
* [pickset](helpers/pickset.md)
* [set](helpers/set.md)
* [shuffle](helpers/shuffle.md)
* Miscellaneous
* [coin](miscellaneous/coin.md)
* [dice](miscellaneous/dice.md)
* [guid](miscellaneous/guid.md)
* [hash](miscellaneous/hash.md)
* [hidden](miscellaneous/hidden.md)
* [n](miscellaneous/n.md)
* [normal](miscellaneous/normal.md)
* [radio](miscellaneous/radio.md)
* [rpg](miscellaneous/rpg.md)
* [tv](miscellaneous/tv.md)
* [unique](miscellaneous/unique.md)
* [weighted](miscellaneous/weighted.md)
<script type="text/javascript" src="chance.js"></script>
+3
View File
@@ -0,0 +1,3 @@
window.analytics=window.analytics||[],window.analytics.methods=["identify","group","track","page","pageview","alias","ready","on","once","off","trackLink","trackForm","trackClick","trackSubmit"],window.analytics.factory=function(t){return function(){var a=Array.prototype.slice.call(arguments);return a.unshift(t),window.analytics.push(a),window.analytics}};for(var i=0;i<window.analytics.methods.length;i++){var key=window.analytics.methods[i];window.analytics[key]=window.analytics.factory(key)}window.analytics.load=function(t){if(!document.getElementById("analytics-js")){var a=document.createElement("script");a.type="text/javascript",a.id="analytics-js",a.async=!0,a.src=("https:"===document.location.protocol?"https://":"http://")+"cdn.segment.io/analytics.js/v1/"+t+"/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n)}},window.analytics.SNIPPET_VERSION="2.0.9",
window.analytics.load("5u8961mhro");
window.analytics.page();
+24
View File
@@ -0,0 +1,24 @@
# bool
```js
// usages
chance.bool()
chance.bool({ likelihood: 30 })
```
Return a random boolean value (`true` or `false`).
```js
chance.bool();
=> true
```
The default likelihood of success (returning `true`) is 50%.
Can optionally specify the likelihood in percent:
```js
chance.bool({likelihood: 30});
=> false
```
In this case only a 30% likelihood of `true`, and a 70% likelihood of `false`.
+65
View File
@@ -0,0 +1,65 @@
# character
```js
// usages
chance.character()
chance.character({ pool: 'abcde' })
chance.character({ alpha: true })
chance.character({ numeric: true })
chance.character({ casing: 'lower' })
chance.character({ symbols: true })
```
Return a random character.
```js
chance.character();
=> 'v'
```
By default it will return a string with random character from the following
pool.
```js
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()'
```
Optionally specify a pool and the character will be generated with characters
only from that pool.
```js
chance.character({ pool: 'abcde' });
=> 'c'
```
Optionally specify alpha for an alphabetic character.
```js
chance.character({ alpha: true });
=> 'N'
```
Optionally specify numeric for a numeric character.
```js
chance.character({ numeric: true });
=> '8'
```
Default includes both upper and lower case. It's possible to specify one or the
other.
```js
chance.character({ casing: 'lower' });
=> 'j'
```
*Note, wanted to call this key just ```case``` but unfortunately that's a
reserved word in JavaScript for use in a switch statement*
Optionally return only symbols
```js
chance.character({ symbols: true });
=> '%'
```
+22
View File
@@ -0,0 +1,22 @@
# falsy
```js
// usages
chance.falsy()
chance.falsy({ pool: [ NaN, undefined ] })
```
Return a random falsy value (`false`, `null`, `undefined`, `0`, `NaN`, `''`).
```js
chance.falsy();
=> false
```
The default pool can be changed to better meet the needs:
```js
chance.falsy({ pool: [ NaN, undefined ] });
=> NaN
```
+44
View File
@@ -0,0 +1,44 @@
# floating
```js
// usages
chance.floating()
chance.floating({ fixed: 7 })
chance.floating({ min: 0, max: 100 })
```
<p class="pullquote">I wanted to use float or double as the method name but both are JS reserved words even though they aren't really used...</p>
Return a random floating point number.
```js
chance.floating();
=> -211920142886.5024
```
By default it will return a fixed number of at most 4 digits after the decimal.
Note: *at most* 4 digits. This because, unless we returned trailing zeroes
(which aren't allowed on the JavaScript float) we can't guarantee 4 digits after
the decimal. So if random chance comes back with `82383854.2000` then
`82383854.2` is what will be returned.
To retrieve a set number of fixed digits after the decimal, provide it as an option.
```js
chance.floating({ fixed: 7 });
=> -749512327.7447168
```
As with other number functions, can include a min and/or max.
```js
chance.floating({ min: 0, max: 100 });
=> 31.9021
```
Or combine them.
```js
chance.floating({ min: 0, max: 100, fixed: 8 });
=> 45.92367599
```
+42
View File
@@ -0,0 +1,42 @@
# integer
```js
// usage
chance.integer()
chance.integer({ min: -20, max: 20 })
```
<p class="pullquote">9007199254740991 is 2^53 - 1 and is the largest number value in JavaScript</p>
Return a random integer.
_range: -9007199254740991 to 9007199254740991_
See: [Largest number in JavaScript](http://vq.io/16qnIYj)
```js
chance.integer();
=> -1293235
```
Can optionally provide min and max.
```js
chance.integer({ min: -20, max: 20 })
=> -7
```
These min and max are inclusive, so they are included in the range. This means
```js
chance.integer({ min: -2, max: 2 })
```
would return either -2, -1, 0, 1, or 2.
```js
// Specific case
-2 <= random number <= 2
// General case
min <= random number <= max
```
+25
View File
@@ -0,0 +1,25 @@
# letter
```js
// usage
chance.letter()
chance.letter({ casing: 'lower' })
```
Return a random letter.
```js
chance.letter();
=> 'p'
```
By default it will return a random lowercase letter.
<p class="pullquote">Note, wanted to call this option just <strong>case</strong> instead of <strong>casing</strong> but unfortunately that's a reserved word in JavaScript for use in a switch statement</p>
It's possible to specify upper case
```js
chance.letter({casing: 'upper'});
=> 'A'
```
+47
View File
@@ -0,0 +1,47 @@
# natural
```js
// usage
chance.natural()
chance.natural({ min: 1, max: 20 })
```
Return a natural number.
_range: 0 to 9007199254740991_
```js
chance.natural();
=> 125019392395
```
Can optionally provide min and max.
```js
chance.natural({min: 1, max: 20});
=> 14
```
Can optionally provide numbers you wish to exclude.
```js
chance.natural({min: 1, max: 5, exclude: [1, 3]});
=> 2
```
These are inclusive, so they are included in the range. This means
```chance.natural({min: 1, max: 3});``` would return either 1, 2, or 3 or:
```js
// Specific case
1 <= random number <= 3
// General case
min <= random number <= max
```
[Natural Number on Wikipedia][natural]
[natural]: https://en.wikipedia.org/wiki/Natural_number
+41
View File
@@ -0,0 +1,41 @@
# prime
```js
// usage
chance.prime()
chance.prime({ min: 1, max: 20 })
```
Return a prime number.
_default range: 0 to 10000_
```js
chance.prime();
=> 929
```
Can optionally provide min and max.
```js
chance.prime({min: 1, max: 20});
=> 13
```
These are inclusive, so they are included in the range. This means
```chance.prime({min: 2, max: 5});``` would return either 2, 3, or 5 or:
```js
// Specific case
2 <= random number <= 5
// General case
min <= random number <= max
```
[Prime Number on Wikipedia][prime]
[prime]: https://en.wikipedia.org/wiki/Prime_number
+76
View File
@@ -0,0 +1,76 @@
# string
```js
// usage
chance.string()
chance.string({ length: 5 })
chance.string({ min: 5 })
chance.string({ max: 50 })
chance.string({ min: 5, max: 20 })
chance.string({ pool: 'abcde' })
chance.string({ alpha: true })
chance.string({ casing: 'lower' })
chance.string({ symbols: true })
```
Return a random string.
```js
chance.string();
=> 'Z&Q78&fqkPq'
```
By default it will return a string with random length of 5-20 characters and
will contain any of the following characters.
```js
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()[]'
```
Can optionally specify a length and the string will be exactly that length.
```js
chance.string({ length: 5 });
=> 'YN%fG'
```
Can optionally specify a min and the string will have a minimum length
```js
chance.string({ min: 5 });
=> '6(Ow1wF)qjUm%W)B2[Q]'
```
Can optionally specify a max and the string will have a maximum length
```js
chance.string({ max: 20 });
=> 'k7fubkfMS@gs#E'
```
Can optionally specify a pool and the string will be generated with characters
only from that pool.
```js
chance.string({ pool: 'abcde' });
=> 'cccdeeabedebb'
```
Of course these options can also be combined, using length or min and max.
```js
chance.string({ length: 5, pool: 'abcde' });
=> 'cbbdc'
```
```js
chance.string({ min: 5, max: 20, pool: 'abcde' });
=> 'ebddceaaceeda'
```
All the options for [chance.character()](./character.md) are supported:
```js
chance.string({ length: 8, casing: 'upper', alpha: true, numeric: true });
=> '3THK7GB1'
```
+27
View File
@@ -0,0 +1,27 @@
# template
Return a random string matching the given template.
```js
// usage
chance.template('{AA####}')
=> 'ZQ7803'
chance.template('{Aa}-{##}')
=> 'Vr-78'
chance.template('{####}:{####}:{####}')
=> '1628:5987:7803'
```
The template consists of any number of "character replacement" and "character
literal" sequences. A "character replacement" sequence starts with a left
brace, has any number of special replacement characters, and ends with a right
brace. A character literal can be any character except a brace or a backslash.
A literal brace or backslash character can be included in the output by
escaping with a backslash.
The following replacement characters can be used in a replacement sequence:
* "#": a random digit
* "a": a random lower case letter
* "A": a random upper case letter
+108
View File
@@ -0,0 +1,108 @@
.markdown-body a {
color: #c0392b;
}
.menu {
background-color: #c0392b;
}
.-menu-visible .menu-toggle {
background-color: #c0392b;
}
.menu-toggle {
color: #fff;
background-color: #c0392b;
}
.toc-menu .link.-active, .toc-menu .hlink.-active {
box-shadow: inset -2px 0 #fff;
}
.toc-menu .-level-1.-parent > .title {
color: #fff;
}
.toc-menu .-level-1:first-child > .title {
color: #fff;
}
ul.heading-list .hlink, ul.heading-list .hlink:visited {
color: #fff;
}
.toc-menu .link, .toc-menu .link:visited {
color: #fff;
}
ul.heading-list .hlink::before {
background: #fff;
}
.footer-nav a {
color: #c0392b;
}
.footer-nav .label, .footer-nav .left .title {
color: #c0392b;
}
.header-nav.-expanded .icon {
color: #fff;
}
.pullquote {
display: block;
float: right;
padding: 0 0 0 10px;
margin: 0 0 10px 10px;
width: 15.0em;
font-size: 1.0em;
line-height: 1.4em;
color: #666;
border-left: 3px solid #ccc;
}
.markdown-body pre {
background-color: #fdf6e3;
border-radius: 12px;
}
.markdown-body pre code {
background-color: #fdf6e3;
}
a.download {
-webkit-user-select: none;
background: #fff;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,32,0.01)), to(rgba(0,0,32,0.08)));
background-image: -moz-linear-gradient(rgba(0,0,32,0.01), rgba(0,0,32,0.08));
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
color: #202028;
padding: 4px 10px;
border: 1px solid #a8a8af;
text-decoration: none !important;
text-shadow: 0 1px 1px rgba(255,255,255,0.9);
font-size: 14px;
line-height: 19px;
font-family: helvetica, arial, sans-serif;
display: inline-block;
cursor: pointer;
font-weight: bold;
}
a.download:hover {
color: #202028;
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,32,0.01)), to(rgba(0,0,32,0.16)));
background-image: -moz-linear-gradient(rgba(0,0,32,0.01), rgba(0,0,32,0.16));
border-color: #707078;
}
a.download:active {
background-color: rgba(0,0,32,0.05);
background-image: -webkit-gradient(linear, left top, left bottom, from(rgba(0,0,32,0.16)), to(rgba(0,0,32,0.01)));
background-image: -moz-linear-gradient(rgba(0,0,32,0.16), rgba(0,0,32,0.01));
box-shadow: inset 0 2px 2px rgba(0,0,0,0.1);
}
+7494
View File
File diff suppressed because it is too large. Load diff
+5
View File
@@ -0,0 +1,5 @@
!function(){function a(b){if(!(this instanceof a))return null==b?new a:new a(b);if("function"==typeof b)return this.random=b,this;arguments.length&&(this.seed=0);for(var c=0;c<arguments.length;c++){var d=0;if("[object String]"===Object.prototype.toString.call(arguments[c]))for(var e=0;e<arguments[c].length;e++){for(var f=0,g=0;g<arguments[c].length;g++)f=arguments[c].charCodeAt(g)+(f<<6)+(f<<16)-f;d+=f}else d=arguments[c];this.seed+=(arguments.length-c)*d}return this.mt=this.mersenne_twister(this.seed),this.bimd5=this.blueimp_md5(),this.random=function(){return this.mt.random(this.seed)},this}function b(a,b){if(a||(a={}),b)for(var c in b)"undefined"==typeof a[c]&&(a[c]=b[c]);return a}function c(a,b){if(a)throw new RangeError(b)}function d(a){return function(){return this.natural(a)}}function e(a,b){for(var c,d=r(a),e=0,f=d.length;f>e;e++)c=d[e],b[c]=a[c]||b[c]}function f(a,b){for(var c=0,d=a.length;d>c;c++)b[c]=a[c]}function g(a,b){var c=Array.isArray(a),d=b||(c?new Array(a.length):{});return c?f(a,d):e(a,d),d}var h=9007199254740992,i=-h,j="0123456789",k="abcdefghijklmnopqrstuvwxyz",l=k.toUpperCase(),m=j+"abcdef",n=Array.prototype.slice;a.prototype.VERSION="1.0.4";var o=function(){throw new Error("No Base64 encoder available.")};!function(){"function"==typeof btoa?o=btoa:"function"==typeof Buffer&&(o=function(a){return new Buffer(a).toString("base64")})}(),a.prototype.bool=function(a){return a=b(a,{likelihood:50}),c(a.likelihood<0||a.likelihood>100,"Chance: Likelihood accepts values from 0 to 100."),100*this.random()<a.likelihood},a.prototype.character=function(a){a=b(a),c(a.alpha&&a.symbols,"Chance: Cannot specify both alpha and symbols.");var d,e,f="!@#$%^&*()[]";return d="lower"===a.casing?k:"upper"===a.casing?l:k+l,e=a.pool?a.pool:a.alpha?d:a.symbols?f:d+j+f,e.charAt(this.natural({max:e.length-1}))},a.prototype.floating=function(a){a=b(a,{fixed:4}),c(a.fixed&&a.precision,"Chance: Cannot specify both fixed and precision.");var d,e=Math.pow(10,a.fixed),f=h/e,g=-f;c(a.min&&a.fixed&&a.min<g,"Chance: Min specified is out of range with fixed. Min should be, at least, "+g),c(a.max&&a.fixed&&a.max>f,"Chance: Max specified is out of range with fixed. Max should be, at most, "+f),a=b(a,{min:g,max:f}),d=this.integer({min:a.min*e,max:a.max*e});var i=(d/e).toFixed(a.fixed);return parseFloat(i)},a.prototype.integer=function(a){return a=b(a,{min:i,max:h}),c(a.min>a.max,"Chance: Min cannot be greater than Max."),Math.floor(this.random()*(a.max-a.min+1)+a.min)},a.prototype.natural=function(a){return a=b(a,{min:0,max:h}),c(a.min<0,"Chance: Min cannot be less than zero."),this.integer(a)},a.prototype.string=function(a){a=b(a,{length:this.natural({min:5,max:20})}),c(a.length<0,"Chance: Length cannot be less than zero.");var d=a.length,e=this.n(this.character,d,a);return e.join("")},a.prototype.capitalize=function(a){return a.charAt(0).toUpperCase()+a.substr(1)},a.prototype.mixin=function(b){for(var c in b)a.prototype[c]=b[c];return this},a.prototype.unique=function(a,b,d){c("function"!=typeof a,"Chance: The first argument must be a function.");var e=function(a,b){return-1!==a.indexOf(b)};d&&(e=d.comparator||e);for(var f,g=[],h=0,i=50*b,j=n.call(arguments,2);g.length<b;){var k=JSON.parse(JSON.stringify(j));if(f=a.apply(this,k),e(g,f)||(g.push(f),h=0),++h>i)throw new RangeError("Chance: num is likely too large for sample set")}return g},a.prototype.n=function(a,b){c("function"!=typeof a,"Chance: The first argument must be a function."),"undefined"==typeof b&&(b=1);var d=b,e=[],f=n.call(arguments,2);for(d=Math.max(0,d),null;d--;null)e.push(a.apply(this,f));return e},a.prototype.pad=function(a,b,c){return c=c||"0",a+="",a.length>=b?a:new Array(b-a.length+1).join(c)+a},a.prototype.pick=function(a,b){if(0===a.length)throw new RangeError("Chance: Cannot pick() from an empty array");return b&&1!==b?this.shuffle(a).slice(0,b):a[this.natural({max:a.length-1})]},a.prototype.pickone=function(a){if(0===a.length)throw new RangeError("Chance: Cannot pickone() from an empty array");return a[this.natural({max:a.length-1})]},a.prototype.pickset=function(a,b){if(0===b)return[];if(0===a.length)throw new RangeError("Chance: Cannot pickset() from an empty array");if(0>b)throw new RangeError("Chance: count must be positive number");return b&&1!==b?this.shuffle(a).slice(0,b):[this.pickone(a)]},a.prototype.shuffle=function(a){for(var b=a.slice(0),c=[],d=0,e=Number(b.length),f=0;e>f;f++)d=this.natural({max:b.length-1}),c[f]=b[d],b.splice(d,1);return c},a.prototype.weighted=function(a,b,c){if(a.length!==b.length)throw new RangeError("Chance: length of array and weights must match");for(var d,e=0,f=0;f<b.length;++f)d=b[f],d>0&&(e+=d);if(0===e)throw new RangeError("Chance: no valid entries in array weights");var g,h=this.random()*e,i=0,j=-1;for(f=0;f<b.length;++f){if(d=b[f],i+=d,d>0){if(i>=h){g=f;break}j=f}f===b.length-1&&(g=j)}var k=a[g];return c="undefined"==typeof c?!1:c,c&&(a.splice(g,1),b.splice(g,1)),k},a.prototype.paragraph=function(a){a=b(a);Line truncated
b+"."+c;if(d.extentions){if(Array.isArray(d.extentions))return c=this.pickone(d.extentions),b+"."+c;if(d.extentions.constructor===Object){var g=d.extentions,h=Object.keys(g);return c=this.pickone(g[this.pickone(h)]),b+"."+c}throw new Error("Expect collection of type Array or Object to be passed as an argument ")}if(d.fileType){var i=d.fileType;if(-1!==f.indexOf(i))return c=this.pickone(this.get(e)[i]),b+"."+c;throw new Error("Expect file type value to be 'raster', 'vector', '3d' or 'document' ")}return c=this.pickone(this.get(e)[this.pickone(f)]),b+"."+c};var p={firstNames:{male:{en:["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"],it:["Adolfo","Alberto","Aldo","Alessandro","Alessio","Alfredo","Alvaro","Andrea","Angelo","Angiolo","Antonino","Antonio","Attilio","Benito","Bernardo","Bruno","Carlo","Cesare","Christian","Claudio","Corrado","Cosimo","Cristian","Cristiano","Daniele","Dario","David","Davide","Diego","Dino","Domenico","Duccio","Edoardo","Elia","Elio","Emanuele","Emiliano","Emilio","Enrico","Enzo","Ettore","Fabio","Fabrizio","Federico","Ferdinando","Fernando","Filippo","Francesco","Franco","Gabriele","Giacomo","Giampaolo","Giampiero","Giancarlo","Gianfranco","Gianluca","Gianmarco","Gianni","Gino","Giorgio","Giovanni","Giuliano","Giulio","Giuseppe","Graziano","Gregorio","Guido","Iacopo","Jacopo","Lapo","Leonardo","Lorenzo","Luca","Luciano","Luigi","Manuel","Marcello","Marco","Marino","Mario","Massimiliano","Massimo","Matteo","Mattia","Maurizio","Mauro","Michele","Mirko","Mohamed","Nello","Neri","Niccolò","Nicola","Osvaldo","Otello","Paolo","Pier Luigi","Piero","Pietro","Raffaele","Remo","Renato","Renzo","Riccardo","Roberto","Rolando","Romano","Salvatore","Samuele","Sandro","Sergio","Silvano","Simone","Stefano","Thomas","Tommaso","Ubaldo","Ugo","Umberto","Valerio","Valter","Vasco","Vincenzo","Vittorio"]},female:{en:["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","DeliLine truncated
name:"Cheshire East"},{name:"Cheshire West and Chester"},{name:"Cornwall"},{name:"County Durham"},{name:"Cumbria"},{name:"Darlington"},{name:"Derby"},{name:"Derbyshire"},{name:"Devon"},{name:"Dorset"},{name:"East Riding of Yorkshire"},{name:"East Sussex"},{name:"Essex"},{name:"Gloucestershire"},{name:"Greater London"},{name:"Greater Manchester"},{name:"Halton"},{name:"Hampshire"},{name:"Hartlepool"},{name:"Herefordshire"},{name:"Hertfordshire"},{name:"Hull"},{name:"Isle of Wight"},{name:"Isles of Scilly"},{name:"Kent"},{name:"Lancashire"},{name:"Leicester"},{name:"Leicestershire"},{name:"Lincolnshire"},{name:"Luton"},{name:"Medway"},{name:"Merseyside"},{name:"Middlesbrough"},{name:"Milton Keynes"},{name:"Norfolk"},{name:"North East Lincolnshire"},{name:"North Lincolnshire"},{name:"North Somerset"},{name:"North Yorkshire"},{name:"Northamptonshire"},{name:"Northumberland"},{name:"Nottingham"},{name:"Nottinghamshire"},{name:"Oxfordshire"},{name:"Peterborough"},{name:"Plymouth"},{name:"Poole"},{name:"Portsmouth"},{name:"Reading"},{name:"Redcar and Cleveland"},{name:"Rutland"},{name:"Shropshire"},{name:"Slough"},{name:"Somerset"},{name:"South Gloucestershire"},{name:"South Yorkshire"},{name:"Southampton"},{name:"Southend-on-Sea"},{name:"Staffordshire"},{name:"Stockton-on-Tees"},{name:"Stoke-on-Trent"},{name:"Suffolk"},{name:"Surrey"},{name:"Swindon"},{name:"Telford and Wrekin"},{name:"Thurrock"},{name:"Torbay"},{name:"Tyne and Wear"},{name:"Warrington"},{name:"Warwickshire"},{name:"West Berkshire"},{name:"West Midlands"},{name:"West Sussex"},{name:"West Yorkshire"},{name:"Wiltshire"},{name:"Windsor and Maidenhead"},{name:"Wokingham"},{name:"Worcestershire"},{name:"York"}]},provinces:{ca:[{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"},{name:"Northwest Territories",abbreviation:"NT"},{name:"Nunavut",abbreviation:"NU"},{name:"Yukon",abbreviation:"YT"}],it:[{name:"Agrigento",abbreviation:"AG",code:84},{name:"Alessandria",abbreviation:"AL",code:6},{name:"Ancona",abbreviation:"AN",code:42},{name:"Aosta",abbreviation:"AO",code:7},{name:"L'Aquila",abbreviation:"AQ",code:66},{name:"Arezzo",abbreviation:"AR",code:51},{name:"Ascoli-Piceno",abbreviation:"AP",code:44},{name:"Asti",abbreviation:"AT",code:5},{name:"Avellino",abbreviation:"AV",code:64},{name:"Bari",abbreviation:"BA",code:72},{name:"Barletta-Andria-Trani",abbreviation:"BT",code:72},{name:"Belluno",abbreviation:"BL",code:25},{name:"Benevento",abbreviation:"BN",code:62},{name:"Bergamo",abbreviation:"BG",code:16},{name:"Biella",abbreviation:"BI",code:96},{name:"Bologna",abbreviation:"BO",code:37},{name:"Bolzano",abbreviation:"BZ",code:21},{name:"Brescia",abbreviation:"BS",code:17},{name:"Brindisi",abbreviation:"BR",code:74},{name:"Cagliari",abbreviation:"CA",code:92},{name:"Caltanissetta",abbreviation:"CL",code:85},{name:"Campobasso",abbreviation:"CB",code:70},{name:"Carbonia Iglesias",abbreviation:"CI",code:70},{name:"Caserta",abbreviation:"CE",code:61},{name:"Catania",abbreviation:"CT",code:87},{name:"Catanzaro",abbreviation:"CZ",code:79},{name:"Chieti",abbreviation:"CH",code:69},{name:"Como",abbreviation:"CO",code:13},{name:"Cosenza",abbreviation:"CS",code:78},{name:"Cremona",abbreviation:"CR",code:19},{name:"Crotone",abbreviation:"KR",code:101},{name:"Cuneo",abbreviation:"CN",code:4},{name:"Enna",abbreviation:"EN",code:86},{name:"Fermo",abbreviation:"FM",code:86},{name:"Ferrara",abbreviation:"FE",code:38},{name:"Firenze",abbreviation:"FI",code:48},{name:"Foggia",abbreviation:"FG",code:71},{name:"Forli-Cesena",abbreviation:"FC",code:71},{name:"Frosinone",abbreviation:"FR",code:60},{name:"Genova",abbreviation:"GE",code:10},{name:"Gorizia",abbreviation:"GO",code:31},{name:"Grosseto",abbreviation:"GR",code:53},{name:"Imperia",abbreviation:"IM",code:8},{name:"Isernia",abbreviation:"IS",code:94},{name:"La-Spezia",abbreviation:"SP",code:66},{name:"Latina",abbreviation:"LT",code:59},{name:"Lecce",abbreviation:"LE",code:75},{name:"Lecco",abbreviation:"LC",code:97},{name:"Livorno",abbreviation:"LI",code:49},{name:"Lodi",abbreviation:"LO",code:98},{name:"Lucca",abbreviation:"LU",code:46},{name:"Macerata",abbreviation:"MC",code:43},{name:"Mantova",abbreviation:"MN",code:20},{name:"Massa-Carrara",abbreviation:"MS",code:45},{name:"Matera",abbreviation:"MT",code:77},{name:"Medio Campidano",abbreviation:"VS",code:77},{name:"Messina",abbreviation:"ME",code:83},{name:"Milano",abbreviation:"MI",code:15},{name:"Modena",abbreviation:"MO",code:36},{name:"Monza-Brianza",abbreviation:"MB",code:36},{name:"Napoli",abbreviation:"NA",code:63},{name:"Novara",abbreviation:"NO",code:3},{name:"Nuoro",abbreviation:"NU",code:91},{name:"OgliasLine truncated
},{name:"Pacific SA Standard Time",abbr:"PSST",offset:-4,isdst:!1,text:"(UTC-04:00) Santiago",utc:["America/Santiago","Antarctica/Palmer"]},{name:"Newfoundland Standard Time",abbr:"NDT",offset:-2.5,isdst:!0,text:"(UTC-03:30) Newfoundland",utc:["America/St_Johns"]},{name:"E. South America Standard Time",abbr:"ESAST",offset:-3,isdst:!1,text:"(UTC-03:00) Brasilia",utc:["America/Sao_Paulo"]},{name:"Argentina Standard Time",abbr:"AST",offset:-3,isdst:!1,text:"(UTC-03:00) Buenos Aires",utc:["America/Argentina/La_Rioja","America/Argentina/Rio_Gallegos","America/Argentina/Salta","America/Argentina/San_Juan","America/Argentina/San_Luis","America/Argentina/Tucuman","America/Argentina/Ushuaia","America/Buenos_Aires","America/Catamarca","America/Cordoba","America/Jujuy","America/Mendoza"]},{name:"SA Eastern Standard Time",abbr:"SEST",offset:-3,isdst:!1,text:"(UTC-03:00) Cayenne, Fortaleza",utc:["America/Araguaina","America/Belem","America/Cayenne","America/Fortaleza","America/Maceio","America/Paramaribo","America/Recife","America/Santarem","Antarctica/Rothera","Atlantic/Stanley","Etc/GMT+3"]},{name:"Greenland Standard Time",abbr:"GDT",offset:-2,isdst:!0,text:"(UTC-03:00) Greenland",utc:["America/Godthab"]},{name:"Montevideo Standard Time",abbr:"MST",offset:-3,isdst:!1,text:"(UTC-03:00) Montevideo",utc:["America/Montevideo"]},{name:"Bahia Standard Time",abbr:"BST",offset:-3,isdst:!1,text:"(UTC-03:00) Salvador",utc:["America/Bahia"]},{name:"UTC-02",abbr:"U",offset:-2,isdst:!1,text:"(UTC-02:00) Coordinated Universal Time-02",utc:["America/Noronha","Atlantic/South_Georgia","Etc/GMT+2"]},{name:"Mid-Atlantic Standard Time",abbr:"MDT",offset:-1,isdst:!0,text:"(UTC-02:00) Mid-Atlantic - Old"},{name:"Azores Standard Time",abbr:"ADT",offset:0,isdst:!0,text:"(UTC-01:00) Azores",utc:["America/Scoresbysund","Atlantic/Azores"]},{name:"Cape Verde Standard Time",abbr:"CVST",offset:-1,isdst:!1,text:"(UTC-01:00) Cape Verde Is.",utc:["Atlantic/Cape_Verde","Etc/GMT+1"]},{name:"Morocco Standard Time",abbr:"MDT",offset:1,isdst:!0,text:"(UTC) Casablanca",utc:["Africa/Casablanca","Africa/El_Aaiun"]},{name:"UTC",abbr:"CUT",offset:0,isdst:!1,text:"(UTC) Coordinated Universal Time",utc:["America/Danmarkshavn","Etc/GMT"]},{name:"GMT Standard Time",abbr:"GDT",offset:1,isdst:!0,text:"(UTC) Dublin, Edinburgh, Lisbon, London",utc:["Atlantic/Canary","Atlantic/Faeroe","Atlantic/Madeira","Europe/Dublin","Europe/Guernsey","Europe/Isle_of_Man","Europe/Jersey","Europe/Lisbon","Europe/London"]},{name:"Greenwich Standard Time",abbr:"GST",offset:0,isdst:!1,text:"(UTC) Monrovia, Reykjavik",utc:["Africa/Abidjan","Africa/Accra","Africa/Bamako","Africa/Banjul","Africa/Bissau","Africa/Conakry","Africa/Dakar","Africa/Freetown","Africa/Lome","Africa/Monrovia","Africa/Nouakchott","Africa/Ouagadougou","Africa/Sao_Tome","Atlantic/Reykjavik","Atlantic/St_Helena"]},{name:"W. Europe Standard Time",abbr:"WEDT",offset:2,isdst:!0,text:"(UTC+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna",utc:["Arctic/Longyearbyen","Europe/Amsterdam","Europe/Andorra","Europe/Berlin","Europe/Busingen","Europe/Gibraltar","Europe/Luxembourg","Europe/Malta","Europe/Monaco","Europe/Oslo","Europe/Rome","Europe/San_Marino","Europe/Stockholm","Europe/Vaduz","Europe/Vatican","Europe/Vienna","Europe/Zurich"]},{name:"Central Europe Standard Time",abbr:"CEDT",offset:2,isdst:!0,text:"(UTC+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague",utc:["Europe/Belgrade","Europe/Bratislava","Europe/Budapest","Europe/Ljubljana","Europe/Podgorica","Europe/Prague","Europe/Tirane"]},{name:"Romance Standard Time",abbr:"RDT",offset:2,isdst:!0,text:"(UTC+01:00) Brussels, Copenhagen, Madrid, Paris",utc:["Africa/Ceuta","Europe/Brussels","Europe/Copenhagen","Europe/Madrid","Europe/Paris"]},{name:"Central European Standard Time",abbr:"CEDT",offset:2,isdst:!0,text:"(UTC+01:00) Sarajevo, Skopje, Warsaw, Zagreb",utc:["Europe/Sarajevo","Europe/Skopje","Europe/Warsaw","Europe/Zagreb"]},{name:"W. Central Africa Standard Time",abbr:"WCAST",offset:1,isdst:!1,text:"(UTC+01:00) West Central Africa",utc:["Africa/Algiers","Africa/Bangui","Africa/Brazzaville","Africa/Douala","Africa/Kinshasa","Africa/Lagos","Africa/Libreville","Africa/Luanda","Africa/Malabo","Africa/Ndjamena","Africa/Niamey","Africa/Porto-Novo","Africa/Tunis","Etc/GMT-1"]},{name:"Namibia Standard Time",abbr:"NST",offset:1,isdst:!1,text:"(UTC+01:00) Windhoek",utc:["Africa/Windhoek"]},{name:"GTB Standard Time",abbr:"GDT",offset:3,isdst:!0,text:"(UTC+02:00) Athens, Bucharest",utc:["Asia/Nicosia","Europe/Athens","Europe/Bucharest","Europe/Chisinau"]},{name:"Middle East Standard Time",abbr:"MEDT",offset:3,isdst:!0,text:"(UTC+02:00) Beirut",utc:["Asia/Beirut"]},{name:"Egypt Standard Time",abbr:"EST",offset:2,isdst:!1,text:"(UTC+02:00) Cairo",utc:["Africa/Cairo"]},{name:"Syria Standard Time",abbr:"SDT",offset:3,isdst:!0,text:"(UTC+02:00) Damascus",utc:["Asia/Damascus"]},{name:"E. Europe Standard Time",abbr:"EEDT",offset:3,isdst:!0,text:"(UTC+02:00) E. Europe"},{Line truncated
//# sourceMappingURL=chance.min.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"chance.min.js","sources":["../chance.js"],"names":["Chance","seed","this","random","arguments","length","i","seedling","Object","prototype","toString","call","j","hash","k","charCodeAt","mt","mersenne_twister","bimd5","blueimp_md5","initOptions","options","defaults","testRange","test","errorMessage","RangeError","diceFn","range","natural","_copyObject","source","target","key","keys","o_keys","l","_copyArray","copyObject","_target","isArray","Array","MAX_INT","MIN_INT","NUMBERS","CHARS_LOWER","CHARS_UPPER","toUpperCase","HEX_POOL","slice","VERSION","base64","Error","btoa","Buffer","input","bool","likelihood","character","alpha","symbols","letters","pool","casing","charAt","max","floating","fixed","precision","num","Math","pow","min","integer","num_fixed","toFixed","parseFloat","floor","string","text","n","join","capitalize","word","substr","mixin","obj","func_name","unique","fn","comparator","arr","val","indexOf","result","count","MAX_DUPLICATES","params","clonedParams","JSON","parse","stringify","apply","push","pad","number","width","pick","shuffle","pickone","pickset","old_array","new_array","Number","splice","weighted","weights","trim","sum","weightIndex","chosenIdx","selected","total","lastGoodIdx","chosen","paragraph","sentences","sentence_array","sentence","words","punctuation","word_array","syllable","chr","consonants","vowels","all","syllables","substring","age","ageRange","type","birthday","currentYear","Date","getFullYear","setFullYear","year","date","cpf","formatted","d1","d2","replace","cnpj","first","gender","nationality","get","toLowerCase","extraGenders","concat","last","israelId","x","y","thisDigit","parseInt","mrz","checkDigit","split","multipliers","runningTotal","forEach","idx","pos","generate","opts","issuer","passportNumber","dob","expiry","that","getMonth","getDate","name","middle","middle_initial","prefix","suffix","name_prefixes","prefixes","abbreviation","name_prefix","full","HIDN","idn_pool","idn_chrs","idn","ssn","ssnFour","dashes","ssn_pool","dash","name_suffixes","suffixes","name_suffix","nationalities","android_id","apple_token","wp8_anid2","wp7_anid","guid","bb_pin","avatar","url","URL_BASE","PROTOCOLS","http","https","FILE_TYPES","bmp","gif","jpg","png","FALLBACKS","404","mm","identicon","monsterid","wavatar","retro","blank","RATINGS","g","pg","r","protocol","email","fileExtension","size","fallback","rating","constructor","md5","color","gray","value","delimiter","rgb","hasAlpha","rgbValue","alphaChanal","colorValue","hex","start","end","withHash","simbol","expression","isGrayscale","format","grayscale","domain","tld","fbid","google_analytics","account","property","hashtag","ip","ipv6","ip_addr","klout","semver","include_prerelease","prerelease","rpg","tlds","twitter","domain_prefix","path","extensions","extension","port","address","street","altitude","areacode","parens","city","coordinates","latitude","longitude","countries","country","depth","geohash","geojson","phone","numPick","self","ukNum","parts","section","sections","area","mobile","match","exchange","subscriber","postal","pd","fsa","ldu","counties","county","provinces","province","state","states","us_states_and_dc","territories","armed_forces","short_suffix","street_suffix","street_suffixes","zip","plusfour","ampm","date_string","american","getTime","m","month","raw","daysInMonth","days","numeric","day","hour","twentyfour","minute","second","millisecond","hammertime","months","timestamp","weekday","weekday_only","weekdays","cc","to_generate","cc_type","luhn_calculate","cc_types","types","short_name","currency_types","currency","timezones","timezone","currency_pair","returnAsString","currencies","reduce","acc","item","code","dollar","cents","undefined","euro","toLocaleString","exp","exp_year","exp_month","future","month_int","curMonth","curYear","vat","it_vat","cf","name_generator","isLast","temp","return_value","map","c","date_generator","lettermonths","checkdigit_generator","range1","range2","evens","odds","digit","pl_pesel","controlNumber","pl_nip","pl_regon","d4","d6","d8","d10","d12","d20","d30","d100","thrown","bits","rolls","p","version","guid_pool","variant_pool","luhn_check","str","digits","reverse","file","fileName","fileExtention","fileOptions","poolCollectionKey","typeRange","extention","extentions","extentionObjectCollection","fileType","data","firstNames","male","en","it","female","lastNames","uk","ca","country_regions","us","colorNames","raster","vector","3d","document","abbr","offset","isdst","utc","o_hasOwnProperty","hasOwnProperty","mac_address","separator","networkVersion","mac_pool","mac","normal","mean","dev","normal_pool","s","u","v","norm","sqrt","log","performanceCounter","round","radio","side","fl","set","values","tv","MersenneTwister","BlueImpMD5","N","M","MATRIX_A","UPPER_MASK","LOWER_MASK","mti","init_genrand","init_by_array","init_key","key_length","genrand_int32","mag01","kk","genrand_int31","genrand_real1","genrand_real3","genrand_res53","a","b","safe_add","lsw","msw"Line truncated
+37
View File
@@ -0,0 +1,37 @@
# cc
```js
// usage
chance.cc()
chance.cc({type: 'Mastercard'})
```
<p class="pullquote" data-pullquote='Somewhat obvious warning: Do not use this to hit live payment gateways...' markdown="1"></p>
Generate a random credit card number. This card number will pass the
[Luhn algorithm][Luhn] so it looks like a legit card.
```js
chance.cc();
=> '6304038511073827'
```
Optionally specify a particular type of card to return:
```js
chance.cc({type: 'Mastercard'});
=> '5171206237468496'
```
The type can be specified by the long name, or by the short name:
```js
chance.cc({type: 'mc'});
=> '5103820202214116'
```
The [types][types] are enumerated below.
[Luhn]: http://en.wikipedia.org/wiki/Luhn_algorithm
[types]: #cc_type
+42
View File
@@ -0,0 +1,42 @@
# cc_type
```js
// usage
chance.cc_type()
chance.cc_type({raw: true})
```
Return a random credit card type.
```js
chance.cc_type();
=> 'Visa'
```
Default returns just the name. To return the entire object (consisting of name,
short name, numeric prefix, and length), specify so with the raw flag.
```js
chance.cc_type({raw: true});
=> {name: 'Discover Card', short_name: 'discover', prefix: '6011', length: 16}
```
The available types are (name - *short_name*):
* American Express - *amex*
* Bankcard - *bankcard*
* China UnionPay - *chinaunion*
* Diners Club Carte Blanche - *dccarte*
* Diners Club enRoute - *dcenroute*
* Diners Club International - *dcintl*
* Diners Club United States & Canada - *dcusc*
* Discover Card - *discover*
* InstaPayment - *instapay*
* JCB - *jcb*
* Laser - *laser*
* Maestro - *maestro*
* Mastercard - *mc*
* Solo - *solo*
* Switch - *switch*
* Visa - *visa*
* Visa Electron - *electron*
+13
View File
@@ -0,0 +1,13 @@
# currency
```js
// usage
chance.currency()
```
Generate a random currency.
```js
chance.currency();
=> { code: "TVD", name: "Tuvalu Dollar" }
```
+13
View File
@@ -0,0 +1,13 @@
# currency_pair
```js
// usage
chance.currency_pair()
```
Generate a currency pair. Handy for simulating currency conversions. Guaranteed to return a unique pair (and not the same currency twice).
```js
chance.currency_pair();
=> [{ code: "ALL", name: "Albania Lek" }, { code: "ZWD", name: "Zimbabwe Dollar" }]
```
+30
View File
@@ -0,0 +1,30 @@
# dollar
```js
// usage
chance.dollar()
chance.dollar({max: 250})
```
<p class="pullquote" data-pullquote="Dolla, dolla, bill ya'll" markdown="1"></p>
Return a random dollar amount.
```js
chance.dollar();
=> "$2560.27"
chance.dollar();
=> "$750.99"
```
By default returns dollar amount no larger than 10000. Optionally specify
the max to make it larger (or smaller).
```js
chance.dollar({max: 20});
=> "$15.23"
chance.dollar({max: 10000000})
=> "$5051205.49"
```
+28
View File
@@ -0,0 +1,28 @@
# euro
```js
// usage
chance.euro()
chance.euro({max: 250})
```
Return a random euro amount. Formatting depends on the current locale (samples are displayed with european formatting)
```js
chance.euro();
=> "2.560,27€"
chance.euro();
=> "750.99€"
```
By default returns euro amount no larger than 10000. Optionally specify
the max to make it larger (or smaller).
```js
chance.euro({max: 20});
=> "15,23€"
chance.euro({max: 10000000})
=> "5.051.205,49€"
```
+21
View File
@@ -0,0 +1,21 @@
# exp
```js
// usage
chance.exp()
chance.exp({raw: true})
```
Generate a random credit card expiration.
```js
chance.exp();
=> '10/2020'
```
Optionally specify that a raw object be returned rather than a string
```js
chance.exp({raw: true});
=> {month: '11', year: '2017'}
```
+28
View File
@@ -0,0 +1,28 @@
# exp_month
```js
// usage
chance.exp_month()
chance.exp_month({future: true})
```
Generate a random credit card expiration month.
```js
chance.exp_month();
=> '01'
```
Optionally specify that it must be a later month than the current month.
```js
chance.exp_month({future: true});
=> '10'
```
So if called in June, this would return a random month from July - Dec. If
called in October, would return November or December.
This because many credit card sandboxes require an expiration date later
than the current date so it's necessary when generating an expiration with the
current year to generate a month later than the current month.
+15
View File
@@ -0,0 +1,15 @@
# exp_year
```js
// usage
chance.exp_year()
```
Generate a random credit card expiration year.
```js
chance.exp_year();
=> '2018'
```
Returns a random year between today and 10 years in the future.
+13
View File
@@ -0,0 +1,13 @@
# capitalize
```js
// usage
chance.capitalize(string)
```
Capitalize the first letter of a word
```js
chance.capitalize('bread')
=> 'Bread'
```
+90
View File
@@ -0,0 +1,90 @@
# mixin
```js
// usage
chance.mixin(<Object>)
```
Mixins are a very powerful way to extend **Chance** to fit the needs of your
specific application.
First, if you are thinking of using a mixin for **Chance**, please consider first
whether your use is something from which others may benefit. If so, please
submit a [pull request][PR] rather than using a mixin!
Spread the love and give everyone the benefit of your awesome generator :)
Now, that said, there are bound to be times when you want to generate something
random that is specific to your application but not widely applicable. Enter
mixins!
**Chance** mixins allow you to add one-off methods to **Chance** which you can
use later.
For example, let's say I have a user object which consists of first, last,
and email.
```js
var user = {
first: 'John',
last: 'Smith',
email: 'john@aol.com'
};
```
Let's say I want to be able to randomly generate these user objects.
This is not the type of thing which would be widely applicable as it's specific
to my application so it's perfect for a mixin!
To create a mixin, build an object whose keys are the names of the methods, and
whose values are the functions to be called.
Note: Within each function, you will have access to `chance` itself!
For example, to create a `user` mixin:
```js
chance.mixin({
'user': function() {
return {
first: chance.first(),
last: chance.last(),
email: chance.email()
};
}
});
// Then you can call your mixin
chance.user();
=> {first: 'Eli', last: 'Benson', email: 'gembibuj@dugesan.com'}
```
Mixins can even include other mixins!
For example, to "extend" the user object:
```js
chance.mixin({
'user': function () {
return {
first: chance.first(),
last: chance.last(),
email: chance.email()
};
},
'social_user': function () {
var user = chance.user();
user.network = chance.pick(['facebook', 'twitter']);
return user;
}
});
```
So we have a second mixin here, `social_user` which is using the `user` mixin
and adding to it! Note, these mixins can be defined in any order on the object
if both declared at once.
[PR]: https://github.com/victorquinn/chancejs/pulls
+40
View File
@@ -0,0 +1,40 @@
# pad
```js
// usage
chance.pad(number, width)
chance.pad(number, width, padder)
```
Pad a number with some string until it reaches a desired width.
By default, `chance.pad()` will pad with zeroes. For example, to zero-pad
numbers such that the outcome width is 5, do the following.
```js
chance.pad(45, 5)
=> '00045'
chance.pad(284, 5)
=> '00284'
chance.pad(82843, 5)
=> '82843'
```
Notice how every item returned is a string with leading zeroes until the width
is 5 for each one.
Can optionally specify a character if the desire is to pad with something other
than zero.
```js
chance.pad(81, 5, 'Z')
=> 'ZZZ81'
chance.pad(692, 5, 'Z')
=> 'ZZ692'
chance.pad(52859, 5)
=> '52859'
```
+9
View File
@@ -0,0 +1,9 @@
# pick
```js
// usage
chance.pick(array)
chance.pick(array, count)
```
**`pick()` is now deprecated in favor of `pickone()` and `pickset()`**
+13
View File
@@ -0,0 +1,13 @@
# pickone
```js
// usage
chance.pickone(array)
```
Given an array, pick a random element and return it
```js
chance.pickone(['alpha', 'bravo', 'charlie', 'delta', 'echo']);
=> 'delta'
```
+20
View File
@@ -0,0 +1,20 @@
# pickset
```js
// usage
chance.pickset(array, quantity)
```
Given an array, pick some random elements and return them in a new array
```js
chance.pickset(['alpha', 'bravo', 'charlie', 'delta', 'echo'], 3);
=> ['echo', 'alpha', 'bravo']
```
Optionally omit the quantity to retrieve a set with length 1
```js
chance.pickset(['alpha', 'bravo', 'charlie', 'delta', 'echo']);
=> ['delta']
```
+23
View File
@@ -0,0 +1,23 @@
# set
```js
// usage
chance.set(key, value)
```
Used for overriding the default data used by Chance.
For example, if instead of the default set of last names (which were pulled from the U.S. census data and therefore obviously American biased), you could replace the data for the first names with something more suited to your task. For example, if you want instead to pick from last names of houses in *A Song of Ice and Fire*, you could do something like:
```js
chance.set('lastNames', ['Arryn', 'Baratheon', 'Bolton', 'Frey', 'Greyjoy', 'Lannister', 'Martell', 'Stark', 'Targaryen', 'Tully', 'Tyrell']);
// then
chance.last()
=> 'Lannister'
```
This is very handy for internationalization.
Available keys for datasets to override: `firstNames`, `lastNames`, `provinces`, `us_states_and_dc`, `territories`, `armed_forces`, `street_suffixes`, `months`, `cc_types`, `currency_types`
+13
View File
@@ -0,0 +1,13 @@
# shuffle
```js
// usage
chance.shuffle(array)
```
Given an array, scramble the order and return it.
```js
chance.shuffle(['alpha', 'bravo', 'charlie', 'delta', 'echo']);
=> ['echo', 'delta', 'alpha', 'charlie', 'bravo']
```
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

+56
View File
@@ -0,0 +1,56 @@
# ![Chance](./logo.png)
**Chance** is a minimalist generator of random <a href="#true-random">[1]</a>
strings, numbers, etc. to help reduce some monotony particularly while writing
automated tests or anywhere else you need anything random.
**Chance** is open source software and is released under the developer and
business-friendly [MIT License](http://en.wikipedia.org/wiki/MIT_License)
**Chance** is loaded on this site so you can just open the console on your
browser and play!
![Chance Web Inspector](./inspector.png)
<a class="twitter-share-button"
href="https://twitter.com/share"
data-size="large"
data-text="Chance - Utility library to generate random things for JavaScript"
data-hashtags="chancejs,javascript"
data-url="http://chancejs.com/"
data-count="horizontal"
data-via="victorquinn">
Tweet
</a>
<iframe src="https://ghbtns.com/github-btn.html?user=chancejs&repo=chancejs&type=star&count=true" allowtransparency="true" frameborder="0" scrolling="0" width="170px" height="20px"></iframe>
Written by [Victor Quinn](https://www.victorquinn.com)
[![Chance on NPM](https://nodei.co/npm/chance.png?downloads=true)](https://nodei.co/npm/chance/)
<ul class=downloads>
<li>
<a href="chance.js" class="download" download="chance.js">chance.js (for development)</a>
- <i>95KB uncompressed</i>
</li>
<li>
<a href="chance.min.js" class="download">chance.min.js (for production)</a>
– <i>55KB, 17KB when gzipped</i>
</li>
</ul>
Or move on to the [Usage](usage/bower.md) section for many other ways to get and use Chance.
## Acknowledgements & Thanks
Thank you to [Sean McCullough](https://github.com/banksean) for your [Mersenne Twister gist](https://gist.github.com/banksean/300494) on which almost the entirety of this library is dependent. And to Takuji Nishimura and Makoto Matsumoto who wrote the original C version on which Sean's JavaScript gist is based.
And of course a monster thank you to all of the [Contributors](https://github.com/chancejs/chancejs/graphs/contributors) to this project!
<small>© 2013 [Victor Quinn](https://www.victorquinn.com)
Chance and this documentation are released under the terms of the [MIT license](http://opensource.org/licenses/MIT).</small>
<a id="true-random">[1]</a> Of course true mathematicians out there would say that this ought to be considered as only generating pseudo-random things, not true random. For that we'd need some external entropy, not depending on a Mersenne Twister, blah, blah, blah. However, for most practical uses of this library for which it was created and intended, such as generating random names and addresses for automated tests, our random is good enough. But it should probably NOT be used for any cryptographic applications requiring true-random. See [Wikipedia's article](http://vq.io/12hBd84) for more info.
<a href="https://www.gosquared.com/analytics/?utm_campaign=badge"><img src="https://stats.gs/badge" alt="Analytics by GoSquared" /></a>
+21
View File
@@ -0,0 +1,21 @@
# address
```js
// usage
chance.address()
chance.address({short_suffix: true})
```
Generate a random street address
```js
chance.address();
=> '5447 Bazpe Lane'
```
Optionally mandate that it return a short suffix
```js
chance.address({short_suffix: true});
=> '536 Baner Rd'
```
+29
View File
@@ -0,0 +1,29 @@
# altitude
```js
// usage
chance.altitude()
chance.altitude({ fixed: 7 })
chance.altitude({ max: 1000 })
```
Generate a random altitude, in meters.
```js
chance.altitude()
=> 1863.21417
```
By default, includes 5 digits of accuracy after the decimal. Can override with the `fixed` option.
```js
chance.altitude({ fixed: 7 })
=> 6897.8978386
```
By default, max of 8848m (height of Mount Everest), but this can be overridden with the `max` option.
```js
chance.altitude({ max: 1000 })
=> 890.20665
```
+16
View File
@@ -0,0 +1,16 @@
# areacode
```js
// usage
chance.areacode()
```
Generate a random area code
```js
chance.areacode()
=> '(526)'
```
*Note, this is a US area code, we have little support for internationalization
at this time. Hope to fix that in the future!*
+13
View File
@@ -0,0 +1,13 @@
# city
```js
// usage
chance.city()
```
Generate a random city name
```js
chance.city();
=> 'Cowotba'
```
+34
View File
@@ -0,0 +1,34 @@
# coordinates
```js
// usage
chance.coordinates()
chance.coordinates({fixed: 2})
chance.coordinates({format: 'dms'})
```
Generate random coordinates, which are latitude and longitude, comma separated.
```js
chance.coordinates();
=> "-29.52974, 24.52815"
```
By default includes 5 fixed digits after decimal, can specify otherwise.
```js
chance.coordinates({fixed: 2});
=> "-49.16, 68.81"
```
By default cooridnates' format is dd, can specify otherwise.
```js
chance.coordinates({format: 'ddm'});
=> "41°44.9592, 25°56.2622"
```
```js
chance.coordinates({format: 'dms'});
=> "56°2’9.8187”, 79°55’40.6812”"
```
+23
View File
@@ -0,0 +1,23 @@
# country
```js
// usage
chance.country()
chance.country({ full: true })
```
Return a random country.
```js
chance.country();
=> 'LT'
```
By default, returns only the 2 letter ISO 3166-1 code for the country.
Optionally specify that it ought to return a full country name.
```js
chance.country({ full: true });
=> 'Venezuela'
```
+29
View File
@@ -0,0 +1,29 @@
# depth
```js
// usage
chance.depth()
chance.depth({ fixed: 2 })
chance.depth({ min: -1000 })
```
Generate a random depth, in meters. Depths are always negative
```js
chance.depth()
=> -2126.95039
```
By default, includes 5 digits of accuracy after the decimal. Can override with the `fixed` option.
```js
chance.depth({ fixed: 2 })
=> -1542.11
```
By default, maximum (or minimum depending on your frame of reference) depth of -2550 (depth of the Mariana Trench), but this can be overridden with the `min` option.
```js
chance.depth({ min: -1000 })
=> -718.41976
```
+21
View File
@@ -0,0 +1,21 @@
# geohash
```js
// usage
chance.geohash()
chance.geohash({ length: 5 })
```
Generate a random geohash. [More details on what a geohash is](http://en.wikipedia.org/wiki/Geohash).
```js
chance.geohash()
=> 'h9xhn7y'
```
By default, includes 7 characters of accuracy. Can override with the `length` option.
```js
chance.geohash({ length: 5 })
=> 'dr0kr'
```
+43
View File
@@ -0,0 +1,43 @@
# latitude
```js
// usage
chance.latitude()
chance.latitude({fixed: 7})
chance.latitude({format: 'dms'})
```
Generate a random latitude.
```js
chance.latitude();
=> 57.99514
```
_range: -90 to 90_
By default includes 5 fixed digits after decimal, can specify otherwise.
```js
chance.latitude({fixed: 7});
=> -29.6443133
```
By default includes entire range of allowed latitudes, can specify a min and/or max to bound it
```js
chance.latitude({min: 38.7, max: 38.9});
=> 38.82358
```
By default latitudes' format is dd, can specify otherwise.
```js
chance.latitude({format: 'ddm'});
=> "41°44.9592"
```
```js
chance.latitude({format: 'dms'});
=> "56°2’9.8187”"
```
+25
View File
@@ -0,0 +1,25 @@
# locale
```js
// usage
chance.locale()
chance.locale({region: true})
```
Generate a random ISO-639-1 language code
```js
chance.locale();
=> 'ca'
```
Generate a random IETF region code
```js
chance.locale({region: true});
=> 'es-EA'
```
_Note, the language codes comes from the [ISO-639-1 spec](http://www.loc.gov/standards/iso639-2/php/code_list.php)
and the region codes come from [IETF standard](http://data.okfn.org/data/core/language-codes#resource-language-codes-full)_
+43
View File
@@ -0,0 +1,43 @@
# longitude
```js
// usage
chance.longitude()
chance.longitude({fixed: 7})
chance.longitude({format: 'dms'})
```
Generate a random longitude.
```js
chance.longitude();
=> 149.41549
```
_range: -180 to 180_
By default includes 5 fixed digits after decimal, can specify otherwise.
```js
chance.longitude({fixed: 7});
=> 51.4549925
```
By default includes entire range of allowed longitudes, can specify a min and/or max to bound it
```js
chance.longitude({min: -78, max: -77});
=> -77.22644
```
By default longitude' format is dd, can specify otherwise.
```js
chance.longitude({format: 'ddm'});
=> "41°44.9592"
```
```js
chance.longitude({format: 'dms'});
=> "56°2’9.8187”"
```
+41
View File
@@ -0,0 +1,41 @@
# phone
```js
// usage
chance.phone()
chance.phone({ formatted: false })
chance.phone({ country: "fr" })
chance.phone({ country: "fr", mobile: true })
```
Generate a random phone
```js
chance.phone();
=> '(494) 927-2152'
```
By default conforms to [NANP](http://en.wikipedia.org/wiki/North_American_Numbering_Plan) for a proper US phone number.
Optionally disable formatting.
```js
chance.phone({ formatted: false });
=> '2617613391'
```
Optionally specify a country.
```js
chance.phone({ country: 'fr' });
=> '01 60 44 92 67'
```
Note, at current we only have support for `'us'`, `'uk'`, or `'fr'` for countries.
For `uk` and `fr`, optionally specify a mobile phone.
```js
chance.phone({ country: 'uk', mobile: true });
=> '07624 321221'
```
+13
View File
@@ -0,0 +1,13 @@
# postal
```js
// usage
chance.postal()
```
Return a Canadian Postal code. Returned postal code is valid with respect to the Postal District (first character) and format only.
```js
chance.postal();
=> 'R1S 3F4'
```
+13
View File
@@ -0,0 +1,13 @@
# postcode
```js
// usage
chance.postcode()
```
Generate a random (U.K.) postcode. Returned postcode is valid with respect to the Postcode Area (first characters) and format only.
```js
chance.postcode();
=> 'W6 9PF'
```
+33
View File
@@ -0,0 +1,33 @@
# province
```js
// usage
chance.province()
chance.province({full: true})
chance.province({full: true})
```
Return a random province.
```js
chance.province();
=> 'ON'
```
By default, returns only the 2 letter abbreviation for province.
Optionally specify that it ought to return a full province name.
```js
chance.province({full: true});
=> 'Nova Scotia'
```
Optionally specify the country from which it should return the province name.
```js
chance.province({country: 'it', full: true});
=> 'Vicenza'
```
Note, currently support for country is limited to: `'ca', 'it'`.
+62
View File
@@ -0,0 +1,62 @@
# state
```js
// usage
chance.state()
chance.state({ full: true })
chance.state({ territories: true })
chance.state({ armed_forces: true })
chance.state({ us_states_and_dc: false })
chance.state({ country: 'us' })
```
Return a random state.
```js
chance.state();
=> 'AK'
```
By default, returns only the 2 letter abbreviation for state.
Optionally specify that it ought to return a full state name.
```js
chance.state({ full: true });
=> 'Florida'
```
Optionally add U.S. Territories ('American Samoa', 'Federated States of Micronesia', 'Guam', 'Marshall Islands', 'Northern Mariana Islands', 'Puerto Rico', 'Virgin Islands, U.S.') to the mix of randomly selected items:
```js
chance.state({ territories: true, full: true })
=> 'Guam'
```
Optionally add Armed Forces to the list as well:
```js
chance.state({ armed_forces: true, full: true })
=> 'Armed Forces Pacific'
```
For all U.S. states, territories, and armed forces, specify all of them:
```js
chance.state({ armed_forces: true, territories: true })
=> 'NY'
```
For just territories or armed forces, specify that it ought not return U.S. states:
```js
chance.state({ territories: true, us_states_and_dc: false })
=> 'PR'
```
Optionally specify a country (US specific options are ignored if country is specified and different from `'us'`):
```js
chance.state({ country: 'it', full: true })
=> 'Toscana'
```
+37
View File
@@ -0,0 +1,37 @@
# street
```js
// usage
chance.street()
chance.street({country:it})
```
Generate a random street
```js
chance.street();
=> 'Tesca Circle'
```
Optionally mandate that it returns a short suffix
```js
chance.street({short_suffix: true});
=> 'Jiled St'
```
Optionally specify the number of syllables used to generate the street name
```js
chance.street({syllables: 8});
=> 'Teniefitinusewjircor Junction'
```
Optionally specify a country to localize street prefixes
```js
chance.street({country: 'it'});
=> 'Via Nefba'
```
Note, currently support for country is limited to: `'us', 'it'`.
+23
View File
@@ -0,0 +1,23 @@
# zip
```js
// usage
chance.zip()
chance.zip({plusfour: true})
```
Generate a random (U.S.) zip code.
```js
chance.zip();
=> '90210'
```
Can optionally specify that it ought to return a [Zip+4][zip+4]:
```js
chance.zip({plusfour: true});
=> '01035-1838'
```
[zip+4]: http://vq.io/19rzsve
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

+16
View File
@@ -0,0 +1,16 @@
# coin
```js
// usage
chance.coin()
```
Flip a coin!
```js
chance.coin();
=> 'heads'
chance.coin();
=> 'tails'
```
+29
View File
@@ -0,0 +1,29 @@
# dice
```js
// usage
chance.d4()
chance.d6()
chance.d8()
chance.d10()
chance.d12()
chance.d20()
chance.d30()
chance.d100()
```
<p class="pullquote" data-pullquote='"Any dungeon master worth his weight in geldings goes nowhere without his 20 sided die."' markdown="1"></p>
Return a value equal to the roll of a die.
```js
chance.d20();
=> 13
chance.d6();
=> 4
```
These are just wrappers around natural() but are convenient for use by games.
They return values between 1 and the number after the `d`, so `chance.d4()` returns 1, 2, 3, or 4, just like a 4 sided die would.
+16
View File
@@ -0,0 +1,16 @@
# guid
```js
// usage
chance.guid()
chance.guid({version: 5})
```
Return a random guid, version 5 by default.
```js
chance.guid();
=> 'f0d8368d-85e2-54fb-73c4-2d60374295e3'
chance.guid({version: 4});
=> 'c71f58e3-34af-43c0-b405-2764d6947d21'
```
+35
View File
@@ -0,0 +1,35 @@
# hash
```js
// usage
chance.hash()
chance.hash({length: 25})
chance.hash({casing: 'upper'})
```
Return a random hex hash
```js
chance.hash()
=> 'e5162f27da96ed8e1ae51def1ba643b91d2581d8'
```
By default, the hash is lowercase and 40 hex characters long (same as a git
commit hash).
Optionally specify a length
```js
chance.hash({length: 15})
=> 'c28f57cb599ada4'
```
Optionally specify casing to get a hash with only uppercase letters
rather than the default lowercase
```js
chance.hash({casing: 'upper'})
=> '3F2EB3FB85D88984C1EC4F46A3DBE740B5E0E56E'
```
+59
View File
@@ -0,0 +1,59 @@
# hidden
```js
// usage
chance.cc_types()
chance.mersenne_twister()
chance.mersenne_twister(12345)
chance.months()
chance.name_prefixes()
chance.provinces()
chance.states()
chance.street_suffix()
chance.street_suffixes()
```
These aren't really hidden per se, but just utility methods intended to be used
internally but exposed externally in case they're useful to anyone.
```js
// Return the list of cc types
chance.cc_types()
=> [{name: "American Express", short_name: 'amex', prefix: '34', length: 15}, ...]
// Return a new Mersenne Twister
chance.mersenne_twister()
=> [object Object] // An instance of a Mersenne Twister
// Optionally provide a seed for that twister
chance.mersenne_twister(12345)
=> [object Object] // An instance of a twister with seed 12345
// Return our list of name prefixes
chance.months();
=> [{name: 'January', short_name 'Jan', numeric: '01'}, ...]
// Return our list of name prefixes
chance.name_prefixes();
=> [{name: 'Doctor', abbreviation: 'Dr.'}, {name: 'Miss', abbreviation: 'Miss'}, ...]
// Return the list of provinces
chance.provinces();
=> [{name: 'Alberta', abbreviation: 'AB'}, {name: 'British Columbia', abbreviation: 'BC'}, ...]
// Return the list of states
chance.states();
=> [{name: 'Alabama', abbreviation: 'AL'}, {name: 'Alaska', abbreviation: 'AK'}, ...]
// Return a random street suffix
chance.street_suffix();
=> {name: 'Street', abbreviation: 'St'}
// Return the list of street suffixes
chance.street_suffixes();
=> [{name: 'Avenue', abbreviation: 'Ave'}, {name: 'Boulevard', abbreviation: 'Blvd'}, ...]
```
+35
View File
@@ -0,0 +1,35 @@
# n
```js
// usage
chance.n(chance.email, 5)
chance.n(chance.email, 5, { domain: "socialradar.com" })
```
Provide any function that generates random stuff (usually another **Chance** function) and a number and `n()` will generate an array of items with a length matching the length you specified.
For example, to generate 5 email addresses:
```js
chance.n(chance.email, 5);
=> [ 'nese@me.gov',
'tukvogi@novew.co.uk',
'worzi@jotok.edu',
'wicumafom@lalu.edu',
'hifebwo@abecusa.com' ]
```
Any options that would be sent to the random function can be added following the number.
For example, `chance.email()` has options which can be specified, so you can generate 5 emails with a known domain as follows:
```js
chance.n(chance.email, 5, { domain: "socialradar.com" })
=> [ 'nuvvu@socialradar.com',
'icolul@socialradar.com',
'rig@socialradar.com',
'ca@socialradar.com',
'uc@socialradar.com' ]
```
Note, these items are not guaranteed to be unique. If that is the intent, see [`chance.unique()`](http://chancejs.com/#unique)
+35
View File
@@ -0,0 +1,35 @@
# normal
```js
// usage
chance.normal()
chance.normal({mean: 100})
chance.normal({mean: 100, dev: 15})
```
Return a normally-distributed random variate.
```js
chance.normal()
=> 0.4244767651300604
```
By default this starts with a mean of `0` and a standard deviation of `1` which
is the standard normal distribution.
Optionally specify a mean and/or deviation.
```js
// Notice, since no deviation was specified, using the default of `1`
chance.normal({mean: 100})
=> 99.68352269988522
// For example, to get a random IQ (which by definition has a mean of 100
// and a standard deviation of 15)
chance.normal({mean: 100, dev: 15})
=> 85.11040121833615
```
Used in combination with the above generators, this can be an extremely powerful
way to get more realistic results as often "pure random" results fail to
approximate the real world.
+27
View File
@@ -0,0 +1,27 @@
# radio
```js
// usage
chance.radio()
```
<p class="pullquote" data-pullquote='Broadcast call signs start with a W if east of the Mississippi River and K if west.' markdown="1"></p>
Generate a random radio call sign.
```js
chance.radio();
=> 'KCXW'
```
Optionally specify a side of the Mississippi River to limit stations to that side.
See [K and W](http://en.wikipedia.org/wiki/Call_signs_in_North_America#K_and_W) for more details
```js
chance.radio({side: 'east'});
=> 'WKOQ'
chance.radio({side: 'east'});
=> 'WNOW'
```
+25
View File
@@ -0,0 +1,25 @@
# rpg
```js
// usage
chance.rpg('#d#')
chance.rpg('#d#', {sum: true})
```
Given an input looking like #d#, where the first # is the number of dice to
roll and the second # is the max of each die, returns an array of dice values.
```js
chance.rpg('3d10');
=> [1, 6, 9]
chance.rpg('5d6');
=> [3, 1, 2, 5, 2]
```
Optionally specify a sum be returned rather than an array of dice.
```js
chance.rpg('3d10', {sum: true});
=> 14
```
+25
View File
@@ -0,0 +1,25 @@
# tv
```js
// usage
chance.tv()
chance.tv({side: 'west'})
```
Generate a TV station call sign. This is an alias for `radio()` since they both
follow the same rules.
```js
chance.radio();
=> 'WXTY'
```
Optionally specify a side of the Mississippi River to limit stations to that side.
```js
chance.radio({side: 'west'});
=> 'KCYL'
chance.radio({side: 'west'});
=> 'KQDV'
```
+47
View File
@@ -0,0 +1,47 @@
# unique
```js
// usage
chance.unique(chance.state, 5)
chance.unique(chance.state, 5, { comparator: func })
```
Provide any function that generates random stuff (usually another **Chance** function) and a number and `unique()` will generate a random array of unique (not repeating) items with a length matching the one you specified.
```js
chance.unique(chance.state, 5);
=> ["SC", "WA", "CO", "TX", "ND"]
```
This is helpful when there are a limited number of options and you want a bunch but want to ensure each is different.
Optionally specify the comparator used to determine whether a generated item is in the list of already generated items. By default the comparator just checks to see if the newly generated item is in the array of already generated items. This works for most simple cases (such as `chance.state()`) but will not work if the generated item is an object (because the `Array.prototype.indexOf()` method will not work on an object since 2 objects will not be strictly equal, `===`, unless they are references to the same object).
```js
chance.unique(chance.currency, 2, {
comparator: function(arr, val) {
return arr.reduce(function(acc, item) {
return acc || (item.code === val.code);
}, false);
}
});
=> [{ code: "KYF", name: "Cayman Islands Dollar" }, { code: "CDF", name: "Congo/Kinshasa Franc" }]
```
You can also specify any arbitrary options in this third argument and they'll be passed along to the method you specify as the first.
For example, let's say you want to retrieve 10 unique integers between 0 and 100. This is easily achievable by specifying `chance.integer` as hte function, 10 as the number to retrieve, and a min/max in the options.
```js
chance.unique(chance.integer, 10, {min: 0, max: 100});
=> [78, 49, 7, 87, 59, 89, 84, 62, 60, 63]
```
Note, there could be cases where it is impossible to generate the unique number. For example, if you choose `chance.state` as shown above as the random function and want say, 55 uniques, **Chance** will throw a RangeError because it is impossible to generate 55 uniques because there are only 51 states in the available pool (50 states plus the District of Columbia).
```js
chance.unique(chance.state, 55);
=> RangeError: Chance: num is likely too large for sample set
```
+55
View File
@@ -0,0 +1,55 @@
# weighted
```js
// usage
chance.weighted(['a', 'b'], [100, 1])
chance.weighted(['a', 'b', 'c', 'd'], [1, 2, 3, 4])
```
Provide an array of items, and another array of items specifying the relative weights and **Chance** will select one of those items, obeying the specified weight.
For example, the following code:
```js
chance.weighted(['a', 'b'], [100, 1]);
=> 'a'
```
Will generate `'a'` 100 times more often than `'b'` but still choose one or the other randomly.
The weights are all relative, so if you have more than just two it will ensure that all items are generated relative to all of the weights.
For example, the following code:
```js
chance.weighted(['a', 'b', 'c', 'd'], [1, 2, 3, 4]);
=> 'c'
```
Will generate a letter from the array but will pick `'b'` twice as often as it picks `'a'` and will pick `'c'` three times as often as it picks `'a'` and will pick `'d'` four times as often as it will pick `'a'` and will pick `'d'` two times as often as it will pick `'b'`.
The weights can be whole numbers as shown above or fractions.
```js
chance.weighted(['a', 'b', 'c', 'd'], [0.1, 0.2, 0.3, 0.4]);
=> 'd'
```
There is no requirement that the weights sum to anything in particular, they are all compared relative to each other so all of the following are equivalent:
```js
chance.weighted(['a', 'b', 'c', 'd'], [1, 2, 3, 4]);
chance.weighted(['a', 'b', 'c', 'd'], [0.1, 0.2, 0.3, 0.4]);
chance.weighted(['a', 'b', 'c', 'd'], [100, 200, 300, 400]);
chance.weighted(['a', 'b', 'c', 'd'], [17, 34, 51, 68]);
chance.weighted(['a', 'b', 'c', 'd'], [0.17, 0.34, 0.51, 0.68]);
```
Recall JavaScript has first class functions so you could do something like the following:
```js
chance.weighted([chance.fbid, chance.twitter, chance.ip], [10, 5, 1])();
=> 10000345166213
```
That will pick one of the **Chance** methods with the relative weights specified and then immediately invoke it, so it will return a random fbid twice as often as it will return a twitter handle (because 10/5 is 2) and an fbid 10 times more often than it will return a random ip address (because 10/1 is 10). It will return a random twitter handle 5 times more often than it will return an ip address (because 5/1 is 5).
+13
View File
@@ -0,0 +1,13 @@
# android_id
```js
// usage
chance.android_id()
```
Return a random GCM registration ID.
```js
chance.android_id()
=> 'APA91HHQyPlWqV2Nu61LRs41eE4vrR4bHLKTs0-Dh5nDLopcWZotLw77NEoJyADNJiq6cwY0jMM02y8aacLs6fe2_ynweFjZJVVevKON-32826v-EFoayyThU3-42YEUY9pCScU_n73yRNSOlTk5W6iPtrDkQ3a6_BvOxRbSYi3E6QEY0ZuIQF0'
```
+13
View File
@@ -0,0 +1,13 @@
# apple_token
```js
// usage
chance.apple_token()
```
Return a random Apple Push Token
```js
chance.apple_token()
=> 'b50edac575bfba07dd019b28b2af7189a3ddda17c806ef14a9abbfd00533f67e'
```
+13
View File
@@ -0,0 +1,13 @@
# bb_pin
```js
// usage
chance.bb_pin()
```
Return a random BlackBerry Device PIN
```js
chance.bb_pin()
=> '985de771'
```
+13
View File
@@ -0,0 +1,13 @@
# wp7_anid
```js
// usage
chance.wp7_anid()
```
Return a random Windows Phone 7 ANID
```js
chance.wp7_anid()
=> 'A=3FC2491A0E0C5AB7824B2F60DCE4DB02&E=4e7&W=6'
```
+13
View File
@@ -0,0 +1,13 @@
# wp8_anid2
```js
// usage
chance.wp8_anid2()
```
Return a random Windows Phone 8 ANID2
```js
chance.wp8_anid2()
=> 'OGI5ODk0MmNkZGI2OGE3YzAwODE1Y2NiYTc4MzEzZjM='
```
+33
View File
@@ -0,0 +1,33 @@
# note
```js
// usage
chance.note();
chance.note({ notes: 'flatkey' });
```
Return a note. 🎵
```js
chance.note();
=> 'B'
chance.note();
=> 'E♭'
```
Options
flatKey - chromatic scale with flat notes (default)
sharpKey - chromatic scale with sharp notes
flats - just flat notes
sharps - just sharp notes
naturals - just natural notes
all - naturals, sharps and flats
```js
chance.note({notes: 'flats' });
=> 'A'
chance.note({notes: 'sharps' });
=> 'F♯'
```
+24
View File
@@ -0,0 +1,24 @@
# tempo
```js
// usage
chance.tempo(); //default between 40 to 320
chance.tempo({ min: 60, max: 120 });
```
Return a tempo. 🎵
```js
chance.tempo();
=> 58
chance.tempo();
=> 281
chance.tempo({ max: 80 });
=> 45
chance.tempo({ min: 120 });
=> 172
```
+31
View File
@@ -0,0 +1,31 @@
# aadhar
_Aadhar_ (English: Foundation) is a 12-digit unique identity number that can be obtained by residents of India, based on their biometric and demographic data.
```js
// usage
chance.aadhar()
chance.aadhar({ onlyLastFour: true }) // false by default
chance.aadhar({ separatedByWhiteSpace: false }) // true by default
```
Generate a random aadhar.
```js
chance.aadhar();
=> '8506 7820 9696'
```
Optionally provide option of getting only the last four
```js
chance.aadhar({ onlyLastFour: true });
=> '1851'
```
Optionally specify dashes be removed
```js
chance.aadhar({ separatedByWhiteSpace: false });
'873300307032'
```
+25
View File
@@ -0,0 +1,25 @@
# age
```js
// usage
chance.age()
chance.age({ type: 'child' })
```
Generate a random age
```js
chance.age();
=> 45
```
Default range is between 1 and 120
Optionally specify one of a handful of enumerated age types:
```js
chance.age({type: 'child'});
=> 9
```
Allowed types are: `child`, `teen`, `adult`, `senior`
+55
View File
@@ -0,0 +1,55 @@
# birthday
```js
// usage
chance.birthday()
chance.birthday({ string: true })
chance.birthday({ type: 'child' })
```
Generate a random birthday
```js
chance.birthday();
=> Fri Aug 16 1985 00:00:00 GMT-0400 (EDT)
```
By default, returns an actual JavaScript [Date][Date] object.
Optionally specify it be returned as a string.
```js
chance.birthday({string: true});
=> '4/1/1968'
```
By default returns in MM/DD/YYYY format. Can specify DD/MM/YYYY as follows:
```js
chance.birthday({string: true, american: false});
=> '28/6/1993'
```
For more complex date formats, use the [Moment][Moment] library.
Can also specify the type, same types as with [age](#age).
```js
chance.birthday({type: 'child'});
=> Sat Sep 08 2001 00:00:00 GMT-0400 (EDT)
```
You can also compose with `chance.year` for interesting combinations. For example, let's say we want to get the birthdays of some renaissance artists (born between 1450 and 1500). We can generate a year and then get a birthday from that year:
```js
var year = chance.year({ min: 1450, max: 1500 });
chance.birthday({ year: year });
=> Wed Aug 27 1484 11:24:14 GMT-0400 (EDT)
// Could be simplified down to one line
chance.birthday({ year: chance.year({ min: 1450, max: 1500 }) });
=> Fri Nov 26 1469 09:17:13 GMT-0500 (EST)
```
[Date]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date
[Moment]: http://momentjs.com
+23
View File
@@ -0,0 +1,23 @@
# cf
```js
// usage
chance.cf()
```
Generate a random Italian social security number (Codice Fiscale).
```js
chance.cf();
=> 'BRSMRT87S49A988X'
```
Optionally specify any or all components: first name, last name, gender, birth date, place of birth (using ISTAT geocodes for Italian cities).
```js
chance.cf({first: 'Sergio', last: 'Leone'});
=> 'LNESRG93P28F067V'
chance.cf({first: 'Sophia', last: 'Loren', gender: 'Female', birthday: new Date(1934,8,20), city: 'h501'});
=> 'LRNSPH34P60H501G'
```
+13
View File
@@ -0,0 +1,13 @@
# cpf
```js
// usage
chance.cpf()
```
Generate a random Brazilian tax id.
```js
chance.cpf();
=> '607.116.899-62'
```
+31
View File
@@ -0,0 +1,31 @@
# first
```js
// usage
chance.first()
chance.first({ nationality: 'us' })
```
Generate a random first name
```js
Chance.first();
=> 'Leila'
```
Optionally specify a gender to limit first names to that gender
```js
Chance.first({ gender: "female" });
=> 'Emma'
```
Optionally specify a nationality to limit first names to those most common of that nationality
```js
Chance.first({ nationality: "it" });
=> 'Alberto'
```
Note, currently support for nationality is limited to: `'us', 'it'`.
+21
View File
@@ -0,0 +1,21 @@
# gender
```js
// usage
chance.gender()
```
Generate a random gender
```js
Chance.gender();
=> 'Female'
```
Extra genders can be provided using the `extraGenders` key in the optional options argument:
```js
Chance.gender({
extraGenders: ['Agender', 'Genderqueer', 'Trans', 'Pangender']
});
```
+23
View File
@@ -0,0 +1,23 @@
# last
```js
// usage
chance.last()
chance.last({ nationality: 'en' })
```
Generate a random last name
```js
Chance.last();
=> 'Mago'
```
Optionally specify a nationality to limit first names to those most common of that nationality
```js
Chance.last({ nationality: 'it' });
=> 'Giovannini'
```
Note, currently support for nationality is limited to: `'en', 'it', 'nl', 'uk', 'de', 'jp', 'es', 'fr'`.
+63
View File
@@ -0,0 +1,63 @@
# name
```js
// usage
chance.name()
chance.name({ middle: true })
chance.name({ middle_initial: true })
chance.name({ prefix: true })
chance.name({ nationality: 'en' })
```
Generate a random name
```js
chance.name();
=> 'Dafi Vatemi'
```
Optionally include the middle name
```js
chance.name({ middle: true });
=> 'Nelgatwu Powuku Heup'
```
Optionally include the middle initial
```js
chance.name({ middle_initial: true });
=> 'Ezme I Iza'
```
Optionally include the prefix
```js
chance.name({ prefix: true });
=> 'Doctor Suosat Am'
```
Optionally include the suffix
```js
chance.name({ suffix: true });
=> 'Fanny Baker Esq.'
```
Optionally specify a gender
```js
chance.name({ gender: 'male' });
=> "Patrick Copeland"
```
Optionally specify a nationality
```js
chance.name({ nationality: 'it' });
=> "Roberta Mazzetti"
```
Note, currently support for nationality is limited to: `'en', 'it'`.
+35
View File
@@ -0,0 +1,35 @@
# prefix
```js
// usage
chance.prefix()
chance.prefix({ full: true })
```
Generate a random name prefix
```js
chance.prefix();
=> 'Mrs.'
```
By default, returns the shorter version.
Optionally get back the full version.
```js
chance.prefix({ full: true });
=> 'Mister'
```
Optionally specify a gender. Valid options are `male`, `female`, or `all` (the default).
```js
chance.prefix({ gender: "male" });
=> 'Mr.'
chance.prefix({ gender: "female" });
=> 'Miss'
```
*To maintain legacy support, this also responds to chance.name_prefix().*
+29
View File
@@ -0,0 +1,29 @@
# ssn
```js
// usage
chance.ssn()
chance.ssn({ ssnFour: true })
chance.ssn({ dashes: false })
```
Generate a random social security number.
```js
chance.ssn();
=> '411-90-0070'
```
Optionally provide option of getting only the last four
```js
chance.ssn({ ssnFour: true });
=> '2938'
```
Optionally specify dashes be removed
```js
chance.ssn({ dashes: false });
=> '293839295'
```
Loaded 100 of 3760 files, more files were not shown because too many files have changed in this diff. Show more