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:
@@ -15,7 +15,7 @@ var srs = require('secure-random-string');
|
||||
var result = srs();
|
||||
|
||||
// Async
|
||||
srs(function(sr) {
|
||||
srs(function(err,sr) {
|
||||
console.log(sr);
|
||||
});
|
||||
|
||||
@@ -40,7 +40,9 @@ srs({length: 256, urlsafe:true}, function(sr) {
|
||||
|
||||
## Error handling
|
||||
|
||||
Will throw error if there is not enough accumulated entropy to generate cryptographically strong data. In other words, this without callback will not block even if all entropy sources are drained.
|
||||
|
||||
An error is possible if there is not enough accumulated entropy to generate cryptographically strong data. In other words, this will not block even if all entropy sources are drained. Note that the sync API throws an exception, while
|
||||
the async API returns the error to the callback.
|
||||
|
||||
## Author
|
||||
|
||||
|
Reference in New Issue
Block a user