3
3
Object . defineProperty ( exports , "__esModule" , {
4
4
value : true
5
5
} ) ;
6
+ exports . DEFAULT_SETTINGS = void 0 ;
6
7
exports . createActionType = createActionType ;
7
8
exports . createRoutine = createRoutine ;
8
- exports [ "default" ] = exports . DEFAULT_SETTINGS = void 0 ;
9
-
9
+ exports [ "default" ] = void 0 ;
10
10
var _reduxActions = require ( "redux-actions" ) ;
11
-
12
- function _defineProperty ( obj , key , value ) { if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
13
-
11
+ function _typeof ( obj ) { "@babel/helpers - typeof" ; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol . iterator ? function ( obj ) { return typeof obj ; } : function ( obj ) { return obj && "function" == typeof Symbol && obj . constructor === Symbol && obj !== Symbol . prototype ? "symbol" : typeof obj ; } , _typeof ( obj ) ; }
12
+ function _defineProperty ( obj , key , value ) { key = _toPropertyKey ( key ) ; if ( key in obj ) { Object . defineProperty ( obj , key , { value : value , enumerable : true , configurable : true , writable : true } ) ; } else { obj [ key ] = value ; } return obj ; }
13
+ function _toPropertyKey ( arg ) { var key = _toPrimitive ( arg , "string" ) ; return _typeof ( key ) === "symbol" ? key : String ( key ) ; }
14
+ function _toPrimitive ( input , hint ) { if ( _typeof ( input ) !== "object" || input === null ) return input ; var prim = input [ Symbol . toPrimitive ] ; if ( prim !== undefined ) { var res = prim . call ( input , hint || "default" ) ; if ( _typeof ( res ) !== "object" ) return res ; throw new TypeError ( "@@toPrimitive must return a primitive value." ) ; } return ( hint === "string" ? String : Number ) ( input ) ; }
14
15
// Default routine settings
15
16
var DEFAULT_SETTINGS = {
16
17
separator : '/' ,
17
18
stages : [ 'TRIGGER' , 'REQUEST' , 'SUCCESS' , 'FAILURE' , 'FULFILL' ]
18
- } ; // Routine action type factory
19
+ } ;
19
20
21
+ // Routine action type factory
20
22
exports . DEFAULT_SETTINGS = DEFAULT_SETTINGS ;
21
-
22
23
function createActionType ( prefix , stage , separator ) {
23
24
if ( typeof prefix !== 'string' || typeof stage !== 'string' ) {
24
25
throw new Error ( 'Invalid routine prefix or stage. It should be string.' ) ;
25
26
}
26
-
27
27
return "" . concat ( prefix ) . concat ( separator ) . concat ( stage ) ;
28
- } // Routine factory
29
-
28
+ }
30
29
30
+ // Routine factory
31
31
function createRoutine ( prefix , payloadCreator , metaCreator , settings ) {
32
32
var _Object$assign = Object . assign ( { } , DEFAULT_SETTINGS , settings ) ,
33
- stages = _Object$assign . stages ,
34
- separator = _Object$assign . separator ;
35
-
33
+ stages = _Object$assign . stages ,
34
+ separator = _Object$assign . separator ;
36
35
var createRoutineAction = function createRoutineAction ( stage ) {
37
36
var type = createActionType ( prefix , stage , separator ) ;
38
37
return ( 0 , _reduxActions . createAction ) ( type , payloadCreator , metaCreator ) ;
39
38
} ;
40
-
41
39
return stages . reduce ( function ( routine , stage ) {
42
40
var _Object$assign2 ;
43
-
44
41
var actionCreator = createRoutineAction ( stage ) ;
45
42
return Object . assign ( routine , ( _Object$assign2 = { } , _defineProperty ( _Object$assign2 , stage . toLowerCase ( ) , actionCreator ) , _defineProperty ( _Object$assign2 , stage . toUpperCase ( ) , actionCreator . toString ( ) ) , _Object$assign2 ) ) ;
46
43
} , createRoutineAction ( stages [ 0 ] ) ) ;
47
44
}
48
-
49
45
var _default = createRoutine ;
50
46
exports [ "default" ] = _default ;
0 commit comments