browserify / browserify/publicEncrypt
Unhealthy code style
- Dominant language
- JavaScript
- Stars
- 28
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Description
I've found you are always prevent to use `for loop` but `for loop` is better than `while loop` in case of determined loop steps. It's more reliable.
E.g:
```
function nonZero (len) {
var out = Buffer.allocUnsafe(len)
var i = 0
var cache = randomBytes(len * 2)
var cur = 0
var num
while (i < len) {
if (cur === cache.length) {
cache = randomBytes(len * 2)
cur = 0
}
num = cache[cur++]
if (num) {
out[i++] = num
}
}
return out
}
```
Could be:
```
function nonZero (len) {
var out = Buffer.allocUnsafe(len)
var cache = randomBytes(len * 2)
var num
for ( var i = 0, cur = 0; i < len; i++) {
if (cur === cache.length) {
cache = randomBytes(len * 2)
cur = 0
}
num = cache[cur++]
if (num) {
out[i] = num
}
}
return out
}
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.