nuid 0.7.2 nuid: ^0.7.2 copied to clipboard
A Dart implementation of NATS (nats.io) Unique Identifiers (uid) inspired by github.com/nats-io/node-nuid.
dart-nuid #
A Dart-lang implementation of NATS Unique Identifiers inspired by node-nuid The NUID contains numbers and capital letters only, i.e. it works with base 36.
Examples: #
Run the example/main.dart
:
dart example/main.dart
import 'package:nuid/nuid.dart';
void main() {
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.next_bytes()}');
}
print(' Reseting nuid:');
nuid.reset();
for(var i = 0; i < 4; i++){
print(' - ${nuid.next_bytes()}');
}
}
As code above shows, there are two methods: next
and next_bytes
.
They return the nuid in a String
and List<int>
format respectively.
The lastone is designed to be compatible with Socket
in dart:io
library.