Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ad0d723

Browse files
committed
Remove len property
1 parent 214d84b commit ad0d723

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/charSet.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@ class CharSet {
44
constructor(chars, ndxFn) {
55
this.chars = chars
66
this.ndxFn = ndxFn
7-
this.len = chars.length
8-
this.entropyPerChar = Math.floor(Math.log2(this.len))
9-
if (this.entropyPerChar != Math.log2(this.len)) {
7+
this.entropyPerChar = Math.floor(Math.log2(chars.length))
8+
if (this.entropyPerChar != Math.log2(chars.length)) {
109
throw new Error('EntropyString only supports CharSets with a power of 2 characters')
1110
}
1211
this.charsPerChunk = lcm(this.entropyPerChar, 8) / this.entropyPerChar
@@ -15,7 +14,7 @@ class CharSet {
1514
use(chars) {
1615
const len = chars.length
1716
// Ensure correct number of characters
18-
if (len != this.len) {
17+
if (len != this.chars.length) {
1918
throw new Error('Invalid character count')
2019
}
2120
// Ensure no repeated characters

0 commit comments

Comments
 (0)