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

fix source files to be compliant with .jscs rules

This commit is contained in:
s2
2017-11-24 09:48:03 +01:00
parent a3cef28167
commit 4689347480
2 changed files with 5 additions and 6 deletions

View File

@@ -16,7 +16,7 @@ function srs(options, cb) {
if (err) { if (err) {
return cb(err); return cb(err);
} }
return cb(null,_finish(buf)); return cb(null, _finish(buf));
}); });
} }
// sync path // sync path
@@ -24,12 +24,11 @@ function srs(options, cb) {
return _finish(crypto.randomBytes(length)); return _finish(crypto.randomBytes(length));
} }
function _finish (buf) { function _finish(buf) {
var string = buf.toString('base64'); var string = buf.toString('base64');
string = string.replace(/\//g,'_').replace(/\+/g,'-'); string = string.replace(/\//g, '_').replace(/\+/g, '-');
return string.substr(0, length); return string.substr(0, length);
} }
}; };

View File

@@ -53,8 +53,8 @@ srs({length: 256}, function(err, sr) {
// sync tests // sync tests
test('generate a random string 32 chars long (sync)', srs().length, 32); test('generate a random string 32 chars long (sync)', srs().length, 32);
test('generate a random string 1 chars long (sync)', srs({length:1}).length, 1); test('generate a random string 1 chars long (sync)', srs({length: 1}).length, 1);
test('generate a random string 256 chars long (sync)', srs({length:256}).length, 256); test('generate a random string 256 chars long (sync)', srs({length: 256}).length, 256);
//in 2000 chars there should be at least one substitution //in 2000 chars there should be at least one substitution