1
0
mirror of https://github.com/S2-/securerandomstring.git synced 2025-08-02 18:30:04 +02:00

1.0.0: Add sync API and update async API to pass error to callback as the first argument.

This commit is contained in:
Mark Stosberg
2015-08-27 16:25:30 -04:00
parent 3358bf21fc
commit 1cc664c4fa
5 changed files with 37 additions and 11 deletions

View File

@@ -11,9 +11,13 @@ function srs(options, cb) {
// async path
if (cb) {
crypto.randomBytes(length, function(ex, buf) {
if (ex) throw ex;
return cb(_finish(buf));
crypto.randomBytes(length, function(err, buf) {
if (err) {
return cb(err)
}
else {
return cb(null,_finish(buf));
}
});
}
// sync path