MCPcopy
hub / github.com/creationix/js-git / deframe

Function deframe

lib/object-codec.js:227–240  ·  view source on GitHub ↗
(buffer, decode)

Source from the content-addressed store, hash-verified

225}
226
227function deframe(buffer, decode) {
228 var space = indexOf(buffer, 0x20);
229 if (space < 0) throw new Error("Invalid git object buffer");
230 var nil = indexOf(buffer, 0x00, space);
231 if (nil < 0) throw new Error("Invalid git object buffer");
232 var body = bodec.slice(buffer, nil + 1);
233 var size = parseDec(buffer, space + 1, nil);
234 if (size !== body.length) throw new Error("Invalid body length.");
235 var type = bodec.toRaw(buffer, 0, space);
236 return {
237 type: type,
238 body: decode ? decoders[type](body) : body
239 };
240}
241
242function indexOf(buffer, byte, i) {
243 i |= 0;

Callers

nothing calls this directly

Calls 2

indexOfFunction · 0.85
parseDecFunction · 0.85

Tested by

no test coverage detected