summaryrefslogtreecommitdiff
path: root/src/node_modules/chance/docs/basics
diff options
context:
space:
mode:
authorMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
committerMinteck <contact@minteck.org>2021-12-21 16:52:28 +0100
commit46e43f4bde4a35785b4997b81e86cd19f046b69b (patch)
treec53c2f826f777f9d6b2d249dab556feb72a6c3a6 /src/node_modules/chance/docs/basics
downloadlangdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.gz
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.tar.bz2
langdetect-46e43f4bde4a35785b4997b81e86cd19f046b69b.zip
Commit
Diffstat (limited to 'src/node_modules/chance/docs/basics')
-rw-r--r--src/node_modules/chance/docs/basics/bool.md24
-rw-r--r--src/node_modules/chance/docs/basics/character.md65
-rw-r--r--src/node_modules/chance/docs/basics/falsy.md22
-rw-r--r--src/node_modules/chance/docs/basics/floating.md44
-rw-r--r--src/node_modules/chance/docs/basics/integer.md42
-rw-r--r--src/node_modules/chance/docs/basics/letter.md25
-rw-r--r--src/node_modules/chance/docs/basics/natural.md47
-rw-r--r--src/node_modules/chance/docs/basics/prime.md41
-rw-r--r--src/node_modules/chance/docs/basics/string.md76
-rw-r--r--src/node_modules/chance/docs/basics/template.md27
10 files changed, 413 insertions, 0 deletions
diff --git a/src/node_modules/chance/docs/basics/bool.md b/src/node_modules/chance/docs/basics/bool.md
new file mode 100644
index 0000000..e5b6a88
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/bool.md
@@ -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`.
+
diff --git a/src/node_modules/chance/docs/basics/character.md b/src/node_modules/chance/docs/basics/character.md
new file mode 100644
index 0000000..6c90ed6
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/character.md
@@ -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 });
+=> '%'
+```
diff --git a/src/node_modules/chance/docs/basics/falsy.md b/src/node_modules/chance/docs/basics/falsy.md
new file mode 100644
index 0000000..24222a4
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/falsy.md
@@ -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
+```
+
+
diff --git a/src/node_modules/chance/docs/basics/floating.md b/src/node_modules/chance/docs/basics/floating.md
new file mode 100644
index 0000000..623e40c
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/floating.md
@@ -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
+```
diff --git a/src/node_modules/chance/docs/basics/integer.md b/src/node_modules/chance/docs/basics/integer.md
new file mode 100644
index 0000000..fbce433
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/integer.md
@@ -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
+```
diff --git a/src/node_modules/chance/docs/basics/letter.md b/src/node_modules/chance/docs/basics/letter.md
new file mode 100644
index 0000000..9f3ed80
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/letter.md
@@ -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'
+```
diff --git a/src/node_modules/chance/docs/basics/natural.md b/src/node_modules/chance/docs/basics/natural.md
new file mode 100644
index 0000000..2127341
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/natural.md
@@ -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
+
diff --git a/src/node_modules/chance/docs/basics/prime.md b/src/node_modules/chance/docs/basics/prime.md
new file mode 100644
index 0000000..a7a45fd
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/prime.md
@@ -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
+
diff --git a/src/node_modules/chance/docs/basics/string.md b/src/node_modules/chance/docs/basics/string.md
new file mode 100644
index 0000000..1ddaddd
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/string.md
@@ -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'
+```
diff --git a/src/node_modules/chance/docs/basics/template.md b/src/node_modules/chance/docs/basics/template.md
new file mode 100644
index 0000000..96ba860
--- /dev/null
+++ b/src/node_modules/chance/docs/basics/template.md
@@ -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
+