Skip to content

Commit

Permalink
feat: v2.0 async API
Browse files Browse the repository at this point in the history
  • Loading branch information
pd4d10 committed Nov 8, 2018
1 parent a6f5693 commit 2f3c92f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/async/generate.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import 'dart:math';
import 'dart:async';

var random = new Random();

Future<String> generate(String alphabet, int size) async {
var len = alphabet.length;
String id = '';
while (0 < size--) {
id += alphabet[random.nextInt(len)];
}
return id;
}
7 changes: 7 additions & 0 deletions lib/async/nanoid.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'dart:async';
import 'generate.dart';
import '../url.dart';

Future<String> nanoid([int size = 21]) async {
return generate(url, size);
}

0 comments on commit 2f3c92f

Please sign in to comment.