(index: number)
| 288 | handleUnshift = (value: any) => () => this.unshift(value); |
| 289 | |
| 290 | remove<T>(index: number): T { |
| 291 | // We need to make sure we also remove relevant pieces of `touched` and `errors` |
| 292 | let result: any; |
| 293 | this.updateArrayField( |
| 294 | // so this gets call 3 times |
| 295 | (array?: any[]) => { |
| 296 | const copy = array ? copyArrayLike(array) : []; |
| 297 | if (!result) { |
| 298 | result = copy[index]; |
| 299 | } |
| 300 | if (isFunction(copy.splice)) { |
| 301 | copy.splice(index, 1); |
| 302 | } |
| 303 | // if the array only includes undefined values we have to return an empty array |
| 304 | return isFunction(copy.every) |
| 305 | ? copy.every(v => v === undefined) |
| 306 | ? [] |
| 307 | : copy |
| 308 | : copy; |
| 309 | }, |
| 310 | true, |
| 311 | true |
| 312 | ); |
| 313 | |
| 314 | return result as T; |
| 315 | } |
| 316 | |
| 317 | handleRemove = (index: number) => () => this.remove<any>(index); |
| 318 |
no test coverage detected