@@ -10,21 +10,22 @@ import Replace from './types/Replace'
1010// import Splice from './types/Splice'
1111
1212function factory ( ) {
13- const TYPE = { Delete, Replace }
14- const patchers = [ Delete . patch , Replace . patch ]
15- const encoders = [ Delete . encode , Replace . encode ]
16- const decoders = [ Delete . decode , Replace . decode ]
13+ const patchers = [ ]
14+ const encoders = [ ]
15+ const decoders = [ ]
1716 const encode = ( object , list = encoders ) => converter ( object , list )
1817 const decode = ( object , list = decoders ) => converter ( object , list )
18+ const applyPatch = applyPatchFactory ( patchers )
19+ const createStore = createStoreFactory ( applyPatch )
20+ const createNode = createNodeFactory ( { encoders, decoders } )
1921 const addType = ( { patch, encode, decode } ) => {
2022 if ( isFunction ( patch ) ) patchers . push ( patch )
2123 if ( isFunction ( encode ) ) encoders . push ( encode )
2224 if ( isFunction ( decode ) ) decoders . push ( decode )
2325 }
2426
25- const applyPatch = applyPatchFactory ( patchers )
26- const createStore = createStoreFactory ( applyPatch )
27- const createNode = createNodeFactory ( { encoders, decoders } )
27+ addType ( Delete )
28+ addType ( Replace )
2829
2930 return {
3031 version,
@@ -36,7 +37,7 @@ function factory() {
3637 createNode,
3738 createStore,
3839 addType,
39- TYPE
40+ TYPE : { Delete , Replace }
4041 }
4142}
4243
0 commit comments