Nuid class
Nuid means NATS UID
NATS is a communication protocol and need an optimized way to generate UIDs for the protocol.
The Nuid is an implementation of the NUID
algorithm based of
the Node.js nuid package
final nuid = Nuid.instance;
print('String:');
print(' First nuid:');
for (var i = 0; i < 4; i++) {
print(' - ${nuid.next()}');
}
print(' Reseting nuid:');
nuid.reset();
for (var i = 0; i < 4; i++) {
print(' - ${nuid.next()}');
}
print('\nBytes:');
print(' First nuid:');
for (var i = 0; i < 4; i++) {
print(' - ${nuid.nextBytes()}');
}
print(' Reseting nuid:');
nuid.reset();
for (var i = 0; i < 4; i++) {
print(' - ${nuid.nextBytes()}');
}
Properties
-
buffer
→ List<
int> -
Makes a copy to keep the
_buf
inmutableno setter - current → String
-
Return the buffer as String
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- inc ↔ int
-
A random number between
minInc
andmaxInc
for incrementingseq
for thenext
generation.getter/setter pair - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seq ↔ int
-
Initial value for generation of a sequence of bytes that increments
in each step based on
inc
.getter/setter pair
Methods
-
next(
) → String - Returns the next Nuid
-
nextBytes(
) → List< int> - Returns the next Nuid as a List<int>
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
reset(
) → void - Initializes or reinitializes a nuid with a crypto random prefix, and pseudo-random sequence and increment.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Constants
- base → const int
- Number of possible digits for an Nuid
- digits → const String
- Valid digits for Nuid (base36)
- maxInc → const int
-
Maximum value for
inc
- maxSeq → const int
-
Maximum value for
seq
- minInc → const int
-
Minimum value for
inc
- preLen → const int
- Number of static prefix of the Nuid
- seqLen → const int
- Number of variable suffix of the Nuid
- totalLen → const int
- Length of a Nuid