跳转到内容
简体中文

randomString

此内容尚不支持你的语言。

randomString(length, exists?): string

Defined in: src/util/RandomString.ts:78

length characters drawn uniformly from the enabled character classes.

Always returns exactly length characters — see fromAlphabet for what makes that a guarantee rather than a best effort. Throws if length is not a non-negative integer, or if every class is disabled: an empty alphabet has nothing to draw from, and failing loudly beats a call that never returns.

exists draws again while it answers true — see ExistsPredicate. It takes this slot when the character classes are left at their defaults and the one after options when they are not; two overloads rather than one third parameter, so that randomString(8, exists) needs no {} placeholder to reach it.

number

ExistsPredicate

string

randomString(length, options, exists?): string

Defined in: src/util/RandomString.ts:83

length characters from the classes options enables, drawing again while exists answers true. Both arguments are documented on the overload above.

number

RandomStringOptions

ExistsPredicate

string