Skip to content

nicknameLengthRange

Every nickname length the language can produce, in characters. This is what randNickname falls back to when minLengthminLengthmin_length or maxLengthmaxLengthmax_length is omitted.

javascript
import { nicknameLengthRange } from 'randino';

nicknameLengthRange('ko'); // [1, 13]
nicknameLengthRange('en'); // [3, 33]
nicknameLengthRange('zh'); // [2, 9]
nicknameLengthRange('ko', '-'); // [1, 15]
ParameterTypeDefaultDescription
languageWordLanguageOption'all'The language, or 'all' for every one
wordSeparatorstringCount what a separator adds between the words

Returns [min, max].

dart
import 'package:randino/randino.dart';

nicknameLengthRange(language: WordLanguage.ko); // LengthRange(1, 13)
nicknameLengthRange(language: WordLanguage.en); // LengthRange(3, 33)
nicknameLengthRange(language: WordLanguage.zh); // LengthRange(2, 9)
nicknameLengthRange(language: WordLanguage.ko, wordSeparator: '-'); // LengthRange(1, 15)
ParameterTypeDefaultDescription
languageWordLanguage?nullThe language, or null for every one
wordSeparatorString?nullCount what a separator adds between the words

Returns a LengthRange, which compares by value.

python
from randino import nickname_length_range

nickname_length_range("ko")  # (1, 13)
nickname_length_range("en")  # (3, 33)
nickname_length_range("zh")  # (2, 9)
nickname_length_range("ko", "-")  # (1, 15)
ParameterTypeDefaultDescription
languageWordLanguageOption"all"The language, or "all" for every one
word_separatorstr | NoneNoneCount what a separator adds between the words

Returns a tuple[int, int].

The range is wide on purpose

The lower end is a bare noun and the upper end a modifier, a noun and a trailing word together, so the default range spans every shape. It is the shape weights rather than the range that decide what output usually looks like, and narrowing the range is how you take a shape away:

javascript
nicknameLengthRange('en'); // [3, 33] — every shape
randNickname({ language: 'en', maxLength: 8, count: 3 });
// ['CoolPoem', 'MaidClaw', 'RustyBus'] — no room for three words
dart
nicknameLengthRange(language: WordLanguage.en); // LengthRange(3, 33) — every shape
randNickname(language: WordLanguage.en, maxLength: 8, count: 3);
// ['CoolPoem', 'MaidClaw', 'RustyBus'] — no room for three words
python
nickname_length_range("en")  # (3, 33) — every shape
rand_nickname(language="en", max_length=8, count=3)
# ['CoolPoem', 'MaidClaw', 'RustyBus'] — no room for three words

Two things that widen or narrow it

A separator is part of the nickname. Its length counts toward minLengthminLengthmin_length / maxLengthmaxLengthmax_length, so passing one to this function is how you find out what is left:

javascript
nicknameLengthRange('ko'); // [1, 13]
nicknameLengthRange('ko', '-'); // [1, 15] — two separators in the longest shape
nicknameLengthRange('en', ' '); // [3, 35]
dart
nicknameLengthRange(language: WordLanguage.ko); // LengthRange(1, 13)
nicknameLengthRange(language: WordLanguage.ko, wordSeparator: '-'); // LengthRange(1, 15)
nicknameLengthRange(language: WordLanguage.en, wordSeparator: ' '); // LengthRange(3, 35)
python
nickname_length_range("ko")  # (1, 13)
nickname_length_range("ko", word_separator="-")  # (1, 15) — two separators in the longest shape
nickname_length_range("en", word_separator=" ")  # (3, 33)

A random suffix is outside the range entirely. randSuffix attaches its token after the nickname is finished, so minLengthminLengthmin_length and maxLengthmaxLengthmax_length describe the whole nickname and nothing is excluded from them.

See also

  • randNickname — where the length options are used.
  • Constants — the hard bounds every length option is clamped to.

Released under the MIT License