isbn method
Returns ISBN.
format is optional ISBNFormat.
locale is optional Locale.
Example:
Code().isbn(); // "886-5-33530-286-4"
Code().isbn(format: ISBNFormat.isbn10); // "8-81232-519-8"
Code().isbn(format: ISBNFormat.isbn10, locale: Locale.en); // "1-20167-936-0"
Implementation
String isbn({ISBNFormat? format, Locale? locale}) {
final isbnFormat = format ?? (Random(seed).nextBool() ? .isbn13 : .isbn10);
final localeNumber = locale == null
? '#'
: IntCodeData.isbnGroups(locale: locale);
final mask = isbnFormat == .isbn13
? '###-$localeNumber-#####-###-#'
: '$localeNumber-#####-###-#';
return Rng.customCode(mask: mask, seed: seed);
}