forked from formulajs/formulajs
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathimplementation-stats.js
77 lines (65 loc) · 1.78 KB
/
implementation-stats.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import Table from 'cli-table3'
import * as database from '../src/database.js'
import * as dateTime from '../src/date-time.js'
import * as engineering from '../src/engineering.js'
import * as financial from '../src/financial.js'
import * as information from '../src/information.js'
import * as logical from '../src/logical.js'
import * as lookupReference from '../src/lookup-reference.js'
import * as mathTrig from '../src/math-trig.js'
import * as statistical from '../src/statistical.js'
import * as text from '../src/text.js'
const categories = {
Database: database,
'Date Time': dateTime,
Eningeering: engineering,
Financial: financial,
Information: information,
Logical: logical,
'Loookup Reference': lookupReference,
'Math Trig': mathTrig,
Statistical: statistical,
Text: text
}
const table = new Table({
head: ['Category', 'Total', 'Not Implemented'],
style: { head: [], border: [] }
})
let aggregateTotal = 0
let aggregateNotImplemented = 0
for (const c in categories) {
const categoryName = c
const category = categories[c]
let total = 0
let notImplemented = 0
const inc = (err) => {
if (err.message.includes('not implemented')) {
notImplemented++
}
}
for (const f in category) {
if (typeof category[f] === 'function') {
total++
try {
category[f]()
} catch (err) {
inc(err)
}
}
if (typeof category[f] === 'object') {
for (const s in category[f]) {
total++
try {
category[s]()
} catch (err) {
inc(err)
}
}
}
}
aggregateTotal += total
aggregateNotImplemented += notImplemented
table.push([categoryName, total, notImplemented])
}
table.push(['Totals', aggregateTotal, aggregateNotImplemented])
console.log(table.toString())