MCPcopy
hub / github.com/osnr/TabFS / truncate

Function truncate

extension/background.js:170–179  ·  view source on GitHub ↗
(req)

Source from the content-addressed store, hash-verified

168 async release({fh}) { Cache.removeObjectForHandle(fh); return {}; },
169
170 async truncate(req) {
171 let arr = toUtf8Array(await getData(req));
172 if (req.size !== arr.length) {
173 const newArr = new Uint8Array(req.size);
174 newArr.set(arr.slice(0, Math.min(req.size, arr.length)));
175 arr = newArr;
176 }
177 Cache.setObjectForPath(req.path, arr);
178 await setData(req, utf8ArrayToString(arr)); return {};
179 }
180 });
181 makeRouteWithContents.Cache = Cache;
182 return makeRouteWithContents;

Callers

nothing calls this directly

Calls 1

toUtf8ArrayFunction · 0.85

Tested by

no test coverage detected