@@ -69,6 +69,8 @@ function devtoolPlugin (store) {
69
69
* @param {Function } f
70
70
* @return {* }
71
71
*/
72
+
73
+
72
74
/**
73
75
* Deep copy the given object considering circular structure.
74
76
* This function caches all nested objects and its copies.
@@ -309,11 +311,6 @@ var Store = function Store (options) {
309
311
var plugins = options . plugins ; if ( plugins === void 0 ) plugins = [ ] ;
310
312
var strict = options . strict ; if ( strict === void 0 ) strict = false ;
311
313
312
- var state = options . state ; if ( state === void 0 ) state = { } ;
313
- if ( typeof state === 'function' ) {
314
- state = state ( ) || { } ;
315
- }
316
-
317
314
// store internal state
318
315
this . _committing = false ;
319
316
this . _actions = Object . create ( null ) ;
@@ -340,6 +337,8 @@ var Store = function Store (options) {
340
337
// strict mode
341
338
this . strict = strict ;
342
339
340
+ var state = this . _modules . root . state ;
341
+
343
342
// init root module.
344
343
// this also recursively registers all sub-modules
345
344
// and collects all module getters inside this._wrappedGetters
@@ -892,12 +891,26 @@ var createNamespacedHelpers = function (namespace) { return ({
892
891
mapActions : mapActions . bind ( null , namespace )
893
892
} ) ; } ;
894
893
894
+ /**
895
+ * Normalize the map
896
+ * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ]
897
+ * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ]
898
+ * @param {Array|Object } map
899
+ * @return {Object }
900
+ */
895
901
function normalizeMap ( map ) {
896
902
return Array . isArray ( map )
897
903
? map . map ( function ( key ) { return ( { key : key , val : key } ) ; } )
898
904
: Object . keys ( map ) . map ( function ( key ) { return ( { key : key , val : map [ key ] } ) ; } )
899
905
}
900
906
907
+ /**
908
+ * Normalize the namespace, and package by fn
909
+ * normalizeMap([1, 2, 3]) => [ { key: 1, val: 1 }, { key: 2, val: 2 }, { key: 3, val: 3 } ]
910
+ * normalizeMap({a: 1, b: 2, c: 3}) => [ { key: 'a', val: 1 }, { key: 'b', val: 2 }, { key: 'c', val: 3 } ]
911
+ * @param {Function } fn
912
+ * @return {Function }
913
+ */
901
914
function normalizeNamespace ( fn ) {
902
915
return function ( namespace , map ) {
903
916
if ( typeof namespace !== 'string' ) {
0 commit comments