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

Function arrayifyFields

src/code-gen/codegen-helpers.ts:5–20  ·  view source on GitHub ↗
(
  beforeStr: string,
  arr: string[] | string,
  afterStr: string
)

Source from the content-addressed store, hash-verified

3import { toNatspec } from "./comments";
4
5const arrayifyFields = (
6 beforeStr: string,
7 arr: string[] | string,
8 afterStr: string
9) => {
10 if (Array.isArray(arr) && arr.length === 1) {
11 arr = arr[0];
12 }
13 if (Array.isArray(arr)) {
14 const withCommas = arr.map(
15 (o, i) => `${o}${i === arr.length - 1 ? "" : ","}`
16 );
17 return [beforeStr, withCommas, afterStr];
18 }
19 return [[beforeStr, arr, afterStr].join("")];
20};
21
22export const buildAssemblyBlock = (lines: ArrayJoinInput<string>) => [
23 `assembly {`,

Callers 3

generateFunctionCodeFunction · 0.85
buildFunctionBlockFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected