MCPcopy Create free account
hub / github.com/d1ll0n/stack-packer / buildNestedAssemblyOr

Function buildNestedAssemblyOr

src/code-gen/codegen-helpers.ts:121–141  ·  view source on GitHub ↗
(
  fields: { positioned: ProcessedField["positioned"] }[]
)

Source from the content-addressed store, hash-verified

119}
120
121export function buildNestedAssemblyOr(
122 fields: { positioned: ProcessedField["positioned"] }[]
123): ArrayJoinInput<string> {
124 const positionedFields: string[] = fields.map((f) => f.positioned);
125 const lastIndex = positionedFields.length - 1;
126 const getChunk = (index: number) => {
127 if (index < lastIndex) {
128 const nextChunk = getChunk(index + 1);
129 return [
130 "or(",
131 [
132 `${positionedFields[index]},`,
133 ...(Array.isArray(nextChunk) ? nextChunk : [nextChunk]),
134 ],
135 `)`,
136 ];
137 }
138 return positionedFields[index];
139 };
140 return toArray(getChunk(0));
141}

Callers 2

getEncoderFunction · 0.90
getOverflowCheckFunction · 0.90

Calls 2

toArrayFunction · 0.90
getChunkFunction · 0.85

Tested by

no test coverage detected