From 06e425a21dfb702607bab706eaff367853b89eed Mon Sep 17 00:00:00 2001 From: Yulian Kuncheff Date: Wed, 5 Apr 2023 22:20:12 -0700 Subject: [PATCH] Cleanup and version bump --- CHANGELOG.md | 4 ++++ lib/rng.dart | 8 +++++++- pubspec.yaml | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ad05834..a6164d2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +v4.0.0-beta3-1 + +* Ensure that any custom RNG implementation produces Uint8Lists of length 16. (Thanks @wph44) + v4.0.0-beta3 * **[BREAKING CHANGE]** Replacing UuidUtil rng functions with RNG classes. diff --git a/lib/rng.dart b/lib/rng.dart index f794e5d..547c7e3 100644 --- a/lib/rng.dart +++ b/lib/rng.dart @@ -1,13 +1,19 @@ import 'dart:math'; import 'dart:typed_data'; +// RNG is an abstract class that defines the interface for a random number +// generator. It is used by the UUID class to generate random numbers. +// +// It also ensures that the Uint8List returned by the RNG is of the correct +// length. Throws an [Exception] if the length is not 16. abstract class RNG { const RNG(); Uint8List generate() { final uint8list = generateInternal(); if (uint8list.length != 16) { - throw Exception('The length of the Uint8list returned by the custom RNG must be 16.'); + throw Exception( + 'The length of the Uint8list returned by the custom RNG must be 16.'); } else { return uint8list; } diff --git a/pubspec.yaml b/pubspec.yaml index 9cb29ab..410c50e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: uuid -version: 4.0.0-beta3 +version: 4.0.0-beta3-1 description: > RFC4122 (v1, v4, v5, v6, v7, v8) UUID Generator and Parser for Dart homepage: https://github.com/Daegalus/dart-uuid