@@ -6,34 +6,46 @@ import { assert } from '../../utilities/assert'
66import { fallback } from '../../utilities/fallback'
77import { reducer } from './reducer'
88import {
9- type ActionDefault ,
10- type ActionDescription ,
11- type ActionOption ,
12- type ActionReference ,
13- type Actions ,
14- type Settings ,
15- type State ,
16- TypeAction ,
9+ type InputCountActionDefault ,
10+ type InputCountActionDescription ,
11+ type InputCountActionOption ,
12+ type InputCountActionReference ,
13+ type InputCountActions ,
14+ type InputCountSettings ,
15+ type InputCountState ,
16+ InputCountTypeAction ,
1717} from './types'
1818
19- const fluentReducer = ( log : Actions ) : State => {
19+ const fluentReducer = ( log : InputCountActions ) : InputCountState => {
2020 const reference = (
21- find ( log , ( action ) => action . type === TypeAction . Reference ) as ActionReference | undefined
21+ find ( log , ( action ) => action . type === InputCountTypeAction . Reference ) as
22+ | InputCountActionReference
23+ | undefined
2224 ) ?. payload
2325
24- const description = find ( log , ( action ) => action . type === TypeAction . Description ) ?. payload
26+ const description = find (
27+ log ,
28+ ( action ) => action . type === InputCountTypeAction . Description ,
29+ ) ?. payload
2530
2631 const rlog = reverse ( [ ...log ] )
2732
2833 const _default = fallback (
2934 0 ,
30- ( find ( log , ( action ) => action . type === TypeAction . Default ) as ActionDefault | undefined )
31- ?. payload ,
35+ (
36+ find ( log , ( action ) => action . type === InputCountTypeAction . Default ) as
37+ | InputCountActionDefault
38+ | undefined
39+ ) ?. payload ,
3240 )
3341
34- const isEmpty = log . length === 0 || ! some ( log , ( action ) => action . type === TypeAction . Option )
42+ const isEmpty =
43+ log . length === 0 || ! some ( log , ( action ) => action . type === InputCountTypeAction . Option )
3544
36- const options = filter ( rlog , ( { type } ) => type === TypeAction . Option ) as ActionOption [ ]
45+ const options = filter (
46+ rlog ,
47+ ( { type } ) => type === InputCountTypeAction . Option ,
48+ ) as InputCountActionOption [ ]
3749
3850 const table = assign (
3951 { } ,
@@ -59,76 +71,76 @@ const fluentReducer = (log: Actions): State => {
5971 }
6072}
6173
62- export const count = builder < Settings > ( [
74+ export const count = builder < InputCountSettings > ( [
6375 {
6476 [ Options . Interface ] : ( dispatch ) => ( {
6577 reference ( reference : Reference ) {
6678 assert . reference ( reference )
6779
68- return dispatch < ActionReference > ( {
80+ return dispatch < InputCountActionReference > ( {
6981 payload : reference ,
70- type : TypeAction . Reference ,
82+ type : InputCountTypeAction . Reference ,
7183 } )
7284 } ,
7385 } ) ,
7486 [ Options . Keys ] : [ 'reference' ] ,
7587 [ Options . Once ] : true ,
7688 [ Options . Reducer ] : fluentReducer ,
77- [ Options . Type ] : TypeAction . Reference ,
89+ [ Options . Type ] : InputCountTypeAction . Reference ,
7890 } ,
7991 {
80- [ Options . Dependencies ] : [ TypeAction . Reference ] ,
92+ [ Options . Dependencies ] : [ InputCountTypeAction . Reference ] ,
8193 [ Options . Interface ] : ( dispatch ) => ( {
8294 description ( description : string ) {
8395 assert . string ( description )
8496
85- return dispatch < ActionDescription > ( {
97+ return dispatch < InputCountActionDescription > ( {
8698 payload : description ,
87- type : TypeAction . Description ,
99+ type : InputCountTypeAction . Description ,
88100 } )
89101 } ,
90102 } ) ,
91103 [ Options . Keys ] : [ 'description' ] ,
92104 [ Options . Once ] : true ,
93105 [ Options . Reducer ] : fluentReducer ,
94- [ Options . Type ] : TypeAction . Description ,
106+ [ Options . Type ] : InputCountTypeAction . Description ,
95107 } ,
96108 {
97- [ Options . Conflicts ] : [ TypeAction . Default ] ,
98- [ Options . Dependencies ] : [ TypeAction . Description ] ,
109+ [ Options . Conflicts ] : [ InputCountTypeAction . Default ] ,
110+ [ Options . Dependencies ] : [ InputCountTypeAction . Description ] ,
99111 [ Options . Interface ] : ( dispatch , _ , { options } ) => ( {
100112 option ( ...value : [ string | undefined , string | undefined ] ) {
101113 assert . inputDichotomousOption ( value , options )
102114
103- return dispatch < ActionOption > ( {
115+ return dispatch < InputCountActionOption > ( {
104116 payload : {
105117 decrease : value [ 1 ] ,
106118 increase : value [ 0 ] ,
107119 } ,
108- type : TypeAction . Option ,
120+ type : InputCountTypeAction . Option ,
109121 } )
110122 } ,
111123 } ) ,
112124 [ Options . Keys ] : [ 'option' ] ,
113125 [ Options . Once ] : false ,
114126 [ Options . Reducer ] : fluentReducer ,
115- [ Options . Type ] : TypeAction . Option ,
127+ [ Options . Type ] : InputCountTypeAction . Option ,
116128 } ,
117129 {
118- [ Options . Dependencies ] : [ TypeAction . Option ] ,
130+ [ Options . Dependencies ] : [ InputCountTypeAction . Option ] ,
119131 [ Options . Interface ] : ( dispatch ) => ( {
120132 default ( value : number ) {
121133 assert . number ( value )
122134
123- return dispatch < ActionDefault > ( {
135+ return dispatch < InputCountActionDefault > ( {
124136 payload : value ,
125- type : TypeAction . Default ,
137+ type : InputCountTypeAction . Default ,
126138 } )
127139 } ,
128140 } ) ,
129141 [ Options . Keys ] : [ 'default' ] ,
130142 [ Options . Once ] : true ,
131143 [ Options . Reducer ] : fluentReducer ,
132- [ Options . Type ] : TypeAction . Default ,
144+ [ Options . Type ] : InputCountTypeAction . Default ,
133145 } ,
134146] )
0 commit comments