Skip to content

Commit dd5d207

Browse files
committed
Rename _PrintTypes to ComponentLifecycleLabels
1 parent 7b0606b commit dd5d207

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

src/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
UseLogConfig,
1212
UseLogReturn,
1313
LogConfig,
14-
_PrintTypes,
14+
ComponentLifecycleLabels,
1515
_PrintConfig,
1616
Printer,
1717
} from './types'
@@ -98,15 +98,15 @@ export function useLog({
9898

9999
useEffect(function onMount() {
100100
print({
101-
type: _PrintTypes.Mount,
101+
type: ComponentLifecycleLabels.Mount,
102102
...printProps,
103103
})
104104

105105
prevValueRef.current = value
106106

107107
return function onUnmount() {
108108
print({
109-
type: _PrintTypes.Unmount,
109+
type: ComponentLifecycleLabels.Unmount,
110110
prevValue: prevValueRef.current,
111111
...printProps,
112112
})
@@ -116,7 +116,7 @@ export function useLog({
116116
useEffect(
117117
function onChange() {
118118
print({
119-
type: _PrintTypes.Change,
119+
type: ComponentLifecycleLabels.Change,
120120
prevValue: prevValueRef.current,
121121
...printProps,
122122
})

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export interface UseLogReturn {
7676
export interface _PrintConfig<T> {
7777
value: T
7878
prevValue?: T
79-
type?: _PrintTypes
79+
type?: ComponentLifecycleLabels
8080
styles?: Styles
8181
componentName: string
8282
flags?: _PrintFlags
@@ -99,9 +99,9 @@ export type _PrintFlags =
9999
}
100100

101101
/**
102-
* Label types of print groups
102+
* Label types of component lifecycle stages
103103
*/
104-
export enum _PrintTypes {
104+
export enum ComponentLifecycleLabels {
105105
Mount = 'Mount',
106106
Unmount = 'Unmount',
107107
Change = 'Change',

src/utils.test.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import * as utils from './utils'
2-
import { _PrintConfig, _PrintTypes, Printer } from './types'
2+
import { _PrintConfig, ComponentLifecycleLabels, Printer } from './types'
33

44
const { getGroupLabel, getComponentName, print, getPrinter, getMessage } = utils
55

66
describe('utils', () => {
77
jest.spyOn(utils, 'getCurrentTime').mockReturnValue('09:38 PM')
88
describe('getGroupLabel', () => {
99
it('renders', () => {
10-
expect(getGroupLabel(_PrintTypes.Change)).toEqual('Change @ 09:38 PM')
10+
expect(getGroupLabel(ComponentLifecycleLabels.Change)).toEqual(
11+
'Change @ 09:38 PM',
12+
)
1113
})
1214

1315
it('renders with component name', () => {
14-
expect(getGroupLabel(_PrintTypes.Mount, 'TestComponent')).toEqual(
15-
'Mount in <TestComponent /> @ 09:38 PM',
16-
)
16+
expect(
17+
getGroupLabel(ComponentLifecycleLabels.Mount, 'TestComponent'),
18+
).toEqual('Mount in <TestComponent /> @ 09:38 PM')
1719
})
1820
})
1921

src/utils.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
import * as utils from './utils'
2-
import { Printer, _PrintConfig, _PrintTypes, _SupportedConsole } from './types'
2+
import {
3+
Printer,
4+
_PrintConfig,
5+
ComponentLifecycleLabels,
6+
_SupportedConsole,
7+
} from './types'
38
import {
49
CURRENT_VALUE_LABEL,
510
DEFAULT_LABEL_SIZE,
@@ -16,7 +21,7 @@ export function stylePlaceholder(withCss?: boolean): string {
1621
return withCss ? '%c' : ''
1722
}
1823

19-
export function getLabel(type: _PrintTypes): string {
24+
export function getLabel(type: ComponentLifecycleLabels): string {
2025
return `On ${type}`
2126
}
2227

@@ -33,7 +38,7 @@ export function getMessage<T>(
3338
}
3439

3540
export function getGroupLabel(
36-
type: _PrintTypes,
41+
type: ComponentLifecycleLabels,
3742
componentName?: string,
3843
withComponentCSS?: boolean,
3944
withSubValueCSS?: boolean,
@@ -89,7 +94,7 @@ export function print<T>({
8994
isCollapsed: false,
9095
isGrouped: true,
9196
},
92-
type = _PrintTypes.Change,
97+
type = ComponentLifecycleLabels.Change,
9398
styles: { componentCSS, subValueCSS, changeCSS } = {},
9499
printer = {},
95100
logLevel = 'log',

0 commit comments

Comments
 (0)