* Validated block index and throws an error if it's invalid * * @param index - index to validate
(index: unknown)
| 413 | * @param index - index to validate |
| 414 | */ |
| 415 | private validateIndex(index: unknown): void { |
| 416 | if (typeof index !== 'number') { |
| 417 | throw new Error('Index should be a number'); |
| 418 | } |
| 419 | |
| 420 | if (index < 0) { |
| 421 | throw new Error(`Index should be greater than or equal to 0`); |
| 422 | } |
| 423 | |
| 424 | if (index === null) { |
| 425 | throw new Error(`Index should be greater than or equal to 0`); |
| 426 | } |
| 427 | } |
| 428 | } |