Skip to content

Commit 2135d4e

Browse files
committed
Remove deprecated functions
1 parent ba99f8b commit 2135d4e

File tree

2 files changed

+7
-77
lines changed

2 files changed

+7
-77
lines changed

lib/entropy.js

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,17 @@
1-
const { log2 } = Math
2-
const LOG2_OF_10 = log2(10)
3-
4-
const totalOf = (numStrings, log2Risk) => {
5-
if (numStrings === 0) { return 0 }
6-
7-
let N
8-
if (numStrings < 1000) {
9-
N = log2(numStrings) + log2(numStrings - 1)
10-
} else {
11-
N = 2 * log2(numStrings)
12-
}
13-
return (N + log2Risk) - 1
14-
}
15-
161
const bits = (total, risk) => {
172
if (total === 0) { return 0 }
18-
return totalOf(total, log2(risk))
19-
}
203

21-
// CxTBD Mark as obsolete
22-
const bitsWithRiskPower = (total, rPower) => {
23-
const log2Risk = LOG2_OF_10 * rPower
24-
return totalOf(total, log2Risk)
25-
}
4+
const { log2 } = Math
265

27-
// CxTBD Mark as obsolete
28-
const bitsWithPowers = (tPower, rPower) => {
29-
let nBits
30-
if (tPower < 4) {
31-
nBits = bitsWithRiskPower(10 ** tPower, rPower)
6+
let N
7+
if (total < 1000) {
8+
N = log2(total) + log2(total - 1)
329
} else {
33-
nBits = ((((2 * tPower) + rPower) * LOG2_OF_10) - 1)
10+
N = 2 * log2(total)
3411
}
35-
return nBits
12+
return (N + log2(risk)) - 1
3613
}
3714

3815
export default {
39-
bits,
40-
bitsWithRiskPower,
41-
bitsWithPowers
16+
bits
4217
}

test/entropy.js

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,51 +29,6 @@ test('Bits using total, risk', (t) => {
2929
t.is(round(Entropy.bits(100000, 100000)), 49)
3030
})
3131

32-
// CxTBD Remove bitsWithRiskPower in next release
33-
test('Bits using total, risk power', (t) => {
34-
t.is(round(Entropy.bitsWithRiskPower(10, 3)), 15)
35-
t.is(round(Entropy.bitsWithRiskPower(10, 4)), 19)
36-
t.is(round(Entropy.bitsWithRiskPower(10, 5)), 22)
37-
38-
t.is(round(Entropy.bitsWithRiskPower(100, 3)), 22)
39-
t.is(round(Entropy.bitsWithRiskPower(100, 4)), 26)
40-
t.is(round(Entropy.bitsWithRiskPower(100, 5)), 29)
41-
42-
t.is(round(Entropy.bitsWithRiskPower(1000, 3)), 29)
43-
t.is(round(Entropy.bitsWithRiskPower(1000, 4)), 32)
44-
t.is(round(Entropy.bitsWithRiskPower(1000, 5)), 36)
45-
t.is(round(Entropy.bitsWithRiskPower(10000, 3)), 36)
46-
t.is(round(Entropy.bitsWithRiskPower(10000, 4)), 39)
47-
t.is(round(Entropy.bitsWithRiskPower(10000, 5)), 42)
48-
49-
t.is(round(Entropy.bitsWithRiskPower(100000, 3)), 42)
50-
t.is(round(Entropy.bitsWithRiskPower(100000, 4)), 46)
51-
t.is(round(Entropy.bitsWithRiskPower(100000, 5)), 49)
52-
})
53-
54-
// CxTBD Remove bitsWithPowers in next release
55-
test('Bits using total power, risk power', (t) => {
56-
t.is(round(Entropy.bitsWithPowers(1, 3)), 15)
57-
t.is(round(Entropy.bitsWithPowers(1, 4)), 19)
58-
t.is(round(Entropy.bitsWithPowers(1, 5)), 22)
59-
60-
t.is(round(Entropy.bitsWithPowers(2, 3)), 22)
61-
t.is(round(Entropy.bitsWithPowers(2, 4)), 26)
62-
t.is(round(Entropy.bitsWithPowers(2, 5)), 29)
63-
64-
t.is(round(Entropy.bitsWithPowers(3, 3)), 29)
65-
t.is(round(Entropy.bitsWithPowers(3, 4)), 32)
66-
t.is(round(Entropy.bitsWithPowers(3, 5)), 36)
67-
68-
t.is(round(Entropy.bitsWithPowers(4, 3)), 36)
69-
t.is(round(Entropy.bitsWithPowers(4, 4)), 39)
70-
t.is(round(Entropy.bitsWithPowers(4, 5)), 42)
71-
72-
t.is(round(Entropy.bitsWithPowers(5, 3)), 42)
73-
t.is(round(Entropy.bitsWithPowers(5, 4)), 46)
74-
t.is(round(Entropy.bitsWithPowers(5, 5)), 49)
75-
})
76-
7732
// preshing.com tests come from table at http://preshing.com/20110504/hash-collision-probabilities/
7833
test('preshing.com, 32-bit column', (t) => {
7934
t.is(round(Entropy.bits(30084, 10)), 32)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy