@dappnode/dappnodesdk
Version:
dappnodesdk is a tool to make the creation of new dappnode packages as simple as possible. It helps to initialize and publish in ethereum blockchain
21 lines • 753 B
JavaScript
export function groupPinsByBranch(pins) {
var _a, _b;
const pinsByBranch = new Map();
for (const pin of pins) {
const commit = (_a = pin.metadata.keyvalues) === null || _a === void 0 ? void 0 : _a.commit;
const branch = (_b = pin.metadata.keyvalues) === null || _b === void 0 ? void 0 : _b.branch;
const ipfsHash = pin.ipfs_pin_hash;
if (!branch)
continue;
let onBranch = pinsByBranch.get(branch);
if (!onBranch)
onBranch = [];
onBranch.push({ commit, ipfsHash });
pinsByBranch.set(branch, onBranch);
}
return Array.from(pinsByBranch.entries()).map(([branch, pins]) => ({
branch,
pins
}));
}
//# sourceMappingURL=utils.js.map