( manifest: LargeArrayManifest, index: number, executionContext?: ExecutionContext )
| 70 | } |
| 71 | |
| 72 | function readManifestIndexSync( |
| 73 | manifest: LargeArrayManifest, |
| 74 | index: number, |
| 75 | executionContext?: ExecutionContext |
| 76 | ): unknown { |
| 77 | if (!Number.isInteger(index) || index < 0 || index >= manifest.totalCount) { |
| 78 | return undefined |
| 79 | } |
| 80 | |
| 81 | let offset = 0 |
| 82 | for (const chunk of manifest.chunks) { |
| 83 | const nextOffset = offset + chunk.count |
| 84 | if (index < nextOffset) { |
| 85 | const materialized = materializeLargeValueRefSync(chunk.ref, executionContext) |
| 86 | if (materialized === undefined) { |
| 87 | return undefined |
| 88 | } |
| 89 | if (!Array.isArray(materialized)) { |
| 90 | throw new Error('Large array manifest chunk must materialize to an array.') |
| 91 | } |
| 92 | if (materialized.length !== chunk.count) { |
| 93 | throw new Error('Large array manifest chunk count does not match materialized data.') |
| 94 | } |
| 95 | return materialized[index - offset] |
| 96 | } |
| 97 | offset = nextOffset |
| 98 | } |
| 99 | |
| 100 | return undefined |
| 101 | } |
| 102 | |
| 103 | function navigateManifestMetadataOrIndexSync( |
| 104 | manifest: LargeArrayManifest, |
no test coverage detected