Skip to content

Commit 0eeec74

Browse files
committed
Move predefined CharSet declarations
1 parent 3f94b99 commit 0eeec74

File tree

13 files changed

+24
-133
lines changed

13 files changed

+24
-133
lines changed

entropy-string.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
const Random = require('./dist/lib/random').default
2-
const Entropy = require('./dist/lib/entropy').default
32
const CharSet = require('./dist/lib/charset').default
43
const {
54
charset2, charset4, charset8, charset16, charset32, charset64
6-
} = require('./dist/lib/charset')
5+
} = require('./dist/lib/entropy')
76

87
module.exports = {
98
Random,
10-
Entropy,
119
CharSet,
1210
charset2,
1311
charset4,

examples/charSet.js

Lines changed: 0 additions & 111 deletions
This file was deleted.

examples/charSet.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../lib/charset.js

examples/charSets.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const {
44
charset64, charset32, charset16, charset8, charset4, charset2
5-
} = require('./entropy-string')
5+
} = require('./entropy')
66

77
console.log(`\n charset64: ${charset64.chars()}`)
88
console.log(`\n charset32: ${charset32.chars()}`)

examples/custom_chars_1.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Custom characters: HT for coin flip
22

3-
const { Random, charset2 } = require('./entropy-string')
3+
const { Random } = require('./entropy-string')
4+
const { charset2 } = require('./entropy')
45

56
const random = new Random(charset2)
67
let flips = random.string(10)

examples/entropy-string.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const Entropy = require('./entropy').default
33
const CharSet = require('./charset').default
44
const {
55
charset2, charset4, charset8, charset16, charset32, charset64
6-
} = require('./charset')
6+
} = require('./entropy')
77

88
module.exports = {
99
Random,

examples/gen5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const { Random, Entropy, charset16 } = require('./entropy-string')
2-
const { entropyBits } = require('./entropy')
1+
const { Random } = require('./entropy-string')
2+
const { entropyBits, charset16 } = require('./entropy')
33

44
const random = new Random(charset16)
55
const bits = entropyBits(10000, 1000000)

examples/tldr_2.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// Generate a potential of _1 million_ random strings with _1 in a billion_ chance of repeat using
22
// hexadecimal strings.
33

4-
const { Random, charset16 } = require('./entropy-string')
5-
const { entropyBits } = require('./entropy')
4+
const { Random } = require('./entropy-string')
5+
const { entropyBits, charset16 } = require('./entropy')
66

77
const random = new Random(charset16)
88
const bits = entropyBits(1e6, 1e9)

examples/tldr_6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Base 64 character 256 bit token
22

3-
const { Random, charset64 } = require('./entropy-string')
3+
const { Random } = require('./entropy-string')
4+
const { charset64 } = require('./entropy')
45

56
const random = new Random(charset64)
6-
77
const string = random.token()
88

99
console.log(`\n 256 bit token using RFC 4648 URL and file system safe characters: ${string}\n`)

lib/charset.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,3 @@ export default class CharSet {
102102
ndxFn() { return this.getNdxFn() }
103103
bitsPerChar() { return this.getBitsPerChar() }
104104
}
105-
106-
export const charset64 = new CharSet('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_')
107-
export const charset32 = new CharSet('2346789bdfghjmnpqrtBDFGHJLMNPQRT')
108-
export const charset16 = new CharSet('0123456789abcdef')
109-
export const charset8 = new CharSet('01234567')
110-
export const charset4 = new CharSet('ATCG')
111-
export const charset2 = new CharSet('01')

0 commit comments

Comments
 (0)