MCPcopy Index your code
hub / github.com/simstudioai/sim / readManifestIndexSync

Function readManifestIndexSync

apps/sim/executor/variables/resolvers/reference.ts:72–101  ·  view source on GitHub ↗
(
  manifest: LargeArrayManifest,
  index: number,
  executionContext?: ExecutionContext
)

Source from the content-addressed store, hash-verified

70}
71
72function 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
103function navigateManifestMetadataOrIndexSync(
104 manifest: LargeArrayManifest,

Callers 2

navigatePathFunction · 0.85

Calls 1

Tested by

no test coverage detected