MCPcopy Create free account
hub / github.com/isomorphic-git/isomorphic-git / wrap

Method wrap

src/models/GitObject.js:16–29  ·  view source on GitHub ↗

* Wraps a raw object with a Git header. * * @param {Object} params - The parameters for wrapping. * @param {string} params.type - The type of the Git object (e.g., 'blob', 'tree', 'commit'). * @param {Uint8Array} params.object - The raw object data to wrap. * @returns {Uint8Array} The

({ type, object })

Source from the content-addressed store, hash-verified

14 * @returns {Uint8Array} The wrapped Git object as a single buffer.
15 */
16 static wrap({ type, object }) {
17 const header = `${type} ${object.length}\x00`
18 const headerLen = header.length
19 const totalLength = headerLen + object.length
20
21 // Allocate a single buffer for the header and object, rather than create multiple buffers
22 const wrappedObject = new Uint8Array(totalLength)
23 for (let i = 0; i < headerLen; i++) {
24 wrappedObject[i] = header.charCodeAt(i)
25 }
26 wrappedObject.set(object, headerLen)
27
28 return wrappedObject
29 }
30
31 /**
32 * Unwraps a Git object buffer into its type and raw object data.

Callers 9

hashObjectFunction · 0.80
hashObjectFunction · 0.80
_writeObjectFunction · 0.80
fromPackMethod · 0.80
oidMethod · 0.80
jFunction · 0.80

Calls 1

setMethod · 0.45

Tested by

no test coverage detected