-
Notifications
You must be signed in to change notification settings - Fork 53
/
Copy pathlifecycle.js
28 lines (26 loc) · 850 Bytes
/
lifecycle.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
import { add } from './math'
const CALLING_LIFECYCLE_METHODS = 'Calling Lifecycle Methods'
const getLifecycleTime = measures => {
const measurementsByName = measures.filter(
measure =>
measure.name.includes('⚛') &&
measure.name
.split('⚛ ')
.join('')
.includes(CALLING_LIFECYCLE_METHODS)
)
return {
[CALLING_LIFECYCLE_METHODS]: {
totalMethods: measurementsByName.map(measurementByName => {
const methodValue = measurementByName.name.split(':')[1].split(' ')[1]
return Number(methodValue)
}),
timeSpent: measurementsByName.map(measurementByName =>
Number(measurementByName.duration.toFixed(2))
)
}
}
}
const getTotalMethods = store =>
Number(add(store[CALLING_LIFECYCLE_METHODS].totalMethods))
export { getTotalMethods, getLifecycleTime }