Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function encodeTree(body) {
var tree = "";
var names = Object.keys(body).sort(pathCmp);
for (var i = 0, l = names.length; i < l; i++) {
var name = names[i];
var entry = body[name];
tree += entry.mode.toString(8) + " " + name +
"\0" + binary.decodeHex(entry.hash);
}
return tree;
}
function encodeTree(body) {
var tree = "";
if (Array.isArray(body)) throw new TypeError("Tree must be in object form");
var list = Object.keys(body).map(treeMap, body).sort(treeSort);
for (var i = 0, l = list.length; i < l; i++) {
var entry = list[i];
tree += entry.mode.toString(8) + " " + bodec.encodeUtf8(entry.name) +
"\0" + bodec.decodeHex(entry.hash);
}
return bodec.fromRaw(tree);
}
function encodeTree(body : TreeBody) {
let tree = "";
if (Array.isArray(body)) throw new TypeError("Tree must be in object form");
const list = Object.keys(body).map(treeMap, body).sort(treeSort);
for (let i = 0, l = list.length; i < l; i++) {
const entry = list[i];
tree += entry.mode.toString(8) + " " + bodec.encodeUtf8(entry.name) +
"\0" + bodec.decodeHex(entry.hash);
}
return bodec.fromRaw(tree);
}