@@ -120,7 +120,15 @@ export function stringify (data) {
120
120
function replacer ( key ) {
121
121
const val = this [ key ]
122
122
const type = typeof val
123
- if ( type === 'undefined' ) {
123
+ if ( Array . isArray ( val ) ) {
124
+ return val
125
+ } else if ( typeof val === 'string' ) {
126
+ if ( val . length > MAX_STRING_SIZE ) {
127
+ return val . substr ( 0 , MAX_STRING_SIZE ) + `... (${ ( val . length ) } total length)`
128
+ } else {
129
+ return val
130
+ }
131
+ } else if ( type === 'undefined' ) {
124
132
return UNDEFINED
125
133
} else if ( val === Infinity ) {
126
134
return INFINITY
@@ -131,14 +139,15 @@ function replacer (key) {
131
139
} else if ( type === 'symbol' ) {
132
140
return `[native Symbol ${ Symbol . prototype . toString . call ( val ) } ]`
133
141
} else if ( val !== null && type === 'object' ) {
134
- if ( val instanceof Map || val . toString ( ) === '[object Map]' ) {
142
+ const proto = Object . prototype . toString . call ( val )
143
+ if ( proto === '[object Map]' ) {
135
144
return encodeCache . cache ( val , ( ) => getCustomMapDetails ( val ) )
136
- } else if ( val instanceof Set || val . toString ( ) === '[object Set]' ) {
145
+ } else if ( proto === '[object Set]' ) {
137
146
return encodeCache . cache ( val , ( ) => getCustomSetDetails ( val ) )
138
- } else if ( val instanceof RegExp ) {
147
+ } else if ( proto === '[object RegExp]' ) {
139
148
// special handling of native type
140
149
return `[native RegExp ${ RegExp . prototype . toString . call ( val ) } ]`
141
- } else if ( val instanceof Date ) {
150
+ } else if ( proto === '[object Date]' ) {
142
151
return `[native Date ${ Date . prototype . toString . call ( val ) } ]`
143
152
} else if ( val . state && val . _vm ) {
144
153
return encodeCache . cache ( val , ( ) => getCustomStoreDetails ( val ) )
@@ -151,8 +160,6 @@ function replacer (key) {
151
160
}
152
161
} else if ( Number . isNaN ( val ) ) {
153
162
return NAN
154
- } else if ( typeof val === 'string' && val . length > MAX_STRING_SIZE ) {
155
- return val . substr ( 0 , MAX_STRING_SIZE ) + `... (${ ( val . length ) } total length)`
156
163
}
157
164
return sanitize ( val )
158
165
}
0 commit comments