Use random.chance instead of random.number === n
This commit is contained in:
parent
e891f28fa6
commit
ddc48c2045
1 changed files with 4 additions and 4 deletions
|
@ -5,21 +5,21 @@
|
||||||
utils.mutate = {
|
utils.mutate = {
|
||||||
text: function (str) {
|
text: function (str) {
|
||||||
let mutator = function (m) {
|
let mutator = function (m) {
|
||||||
return random.number(4) === 1 ? m : make.text.any()
|
return random.chance(4) ? m : make.text.any()
|
||||||
}
|
}
|
||||||
return str.replace(/[a-zA-Z]+?/g, mutator)
|
return str.replace(/[a-zA-Z]+?/g, mutator)
|
||||||
},
|
},
|
||||||
|
|
||||||
numbers: function (str) {
|
numbers: function (str) {
|
||||||
let mutator = function (m) {
|
let mutator = function (m) {
|
||||||
return random.number(4) === 1 ? m : make.number.any()
|
return random.chance(4) ? m : make.number.any()
|
||||||
}
|
}
|
||||||
return str.replace(/-?\d+(\.\d+)?/g, mutator)
|
return str.replace(/-?\d+(\.\d+)?/g, mutator)
|
||||||
},
|
},
|
||||||
|
|
||||||
units: function (str) {
|
units: function (str) {
|
||||||
let mutator = function (m, p1) {
|
let mutator = function (m, p1) {
|
||||||
if (random.number(4) === 1) {
|
if (random.chance(4)) {
|
||||||
return m
|
return m
|
||||||
} else {
|
} else {
|
||||||
return p1 + make.unit.unit()
|
return p1 + make.unit.unit()
|
||||||
|
@ -30,7 +30,7 @@ utils.mutate = {
|
||||||
|
|
||||||
random: function (str) {
|
random: function (str) {
|
||||||
let mutator = function (m) {
|
let mutator = function (m) {
|
||||||
if (random.number(20) === 1) {
|
if (random.chance(20)) {
|
||||||
if (str.match(/[0-9]/g)) {
|
if (str.match(/[0-9]/g)) {
|
||||||
return make.number.any()
|
return make.number.any()
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue