* Default visitor. * * @param {*} value * @param {String|Number} key * @param {Array<String|Number>} path * @this {FormData} * * @returns {boolean} return true to visit the each prop of the value recursively
(value, key, path)
| 198 | * @returns {boolean} return true to visit the each prop of the value recursively |
| 199 | */ |
| 200 | function defaultVisitor(value, key, path) { |
| 201 | let arr = value; |
| 202 | |
| 203 | if (utils.isReactNative(formData) && utils.isReactNativeBlob(value)) { |
| 204 | formData.append(renderKey(path, key, dots), convertValue(value)); |
| 205 | return false; |
| 206 | } |
| 207 | |
| 208 | if (value && !path && typeof value === 'object') { |
| 209 | if (utils.endsWith(key, '{}')) { |
| 210 | // eslint-disable-next-line no-param-reassign |
| 211 | key = metaTokens ? key : key.slice(0, -2); |
| 212 | // eslint-disable-next-line no-param-reassign |
| 213 | value = stringifyWithDepthLimit(value, 1); |
| 214 | } else if ( |
| 215 | (utils.isArray(value) && isFlatArray(value)) || |
| 216 | ((utils.isFileList(value) || utils.endsWith(key, '[]')) && (arr = utils.toArray(value))) |
| 217 | ) { |
| 218 | // eslint-disable-next-line no-param-reassign |
| 219 | key = removeBrackets(key); |
| 220 | |
| 221 | arr.forEach(function each(el, index) { |
| 222 | !(utils.isUndefined(el) || el === null) && |
| 223 | formData.append( |
| 224 | // eslint-disable-next-line no-nested-ternary |
| 225 | indexes === true |
| 226 | ? renderKey([key], index, dots) |
| 227 | : indexes === null |
| 228 | ? key |
| 229 | : key + '[]', |
| 230 | convertValue(el) |
| 231 | ); |
| 232 | }); |
| 233 | return false; |
| 234 | } |
| 235 | } |
| 236 | |
| 237 | if (isVisitable(value)) { |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | formData.append(renderKey(path, key, dots), convertValue(value)); |
| 242 | |
| 243 | return false; |
| 244 | } |
| 245 | |
| 246 | const exposedHelpers = Object.assign(predicates, { |
| 247 | defaultVisitor, |
nothing calls this directly
no test coverage detected