Character generator
Random character generator.
const { character } = require("chance-generators")
Without any arguments it generates random characters from the following pool:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()[]
.
expect(character.take(5), "to equal", ["B", "6", "(", "n", "2"]);
You can limit the generated characters to only be alphanumeric:
expect(character({ alpha: true }).take(5), "to equal", ["t", "P", "X", "j", "M"]);
You can generate only lower-case or upper case letters:
expect(character({ casing: "lower" }).take(5), "to equal", ["r", "#", ")", "i", "9"]);
expect(character({ casing: "upper" }).take(5), "to equal", ["R", "#", ")", "I", "9"]);
You can also chose to only generate symbols:
expect(character({ symbols: true }).take(5), "to equal", ["%", ")", "]", "#", "("]);
You can specify the pool the characters are generated from:
expect(character({ pool: "abc" }).take(5), "to equal", ["b", "c", "c", "a", "c"]);