MCPcopy Create free account
hub / github.com/vercel/vercel / addBytecodeWithinCapacity

Function addBytecodeWithinCapacity

packages/python/src/index.ts:113–137  ·  view source on GitHub ↗
(
  files: Files,
  bytecodeInfo: BytecodeCollectionResult | undefined,
  capacity: number
)

Source from the content-addressed store, hash-verified

111}
112
113function addBytecodeWithinCapacity(
114 files: Files,
115 bytecodeInfo: BytecodeCollectionResult | undefined,
116 capacity: number
117): number {
118 if (!bytecodeInfo || bytecodeInfo.totalSize <= 0 || capacity <= 0) {
119 return capacity;
120 }
121
122 if (bytecodeInfo.totalSize <= capacity) {
123 addFiles(files, bytecodeInfo.files);
124 return capacity - bytecodeInfo.totalSize;
125 }
126
127 const selected = lambdaKnapsack(bytecodeInfo.perItemSizes, capacity);
128 let remainingCapacity = capacity;
129 for (const p of selected) {
130 const file = bytecodeInfo.files[p];
131 if (!file) continue;
132 files[p] = file;
133 remainingCapacity -= bytecodeInfo.perItemSizes.get(p) ?? 0;
134 }
135
136 return remainingCapacity;
137}
138
139async function addVendorBytecodeWithinCapacity({
140 files,

Callers 1

Calls 3

lambdaKnapsackFunction · 0.90
addFilesFunction · 0.85
getMethod · 0.65

Tested by

no test coverage detected