First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
import { findPaginatedResourcePath, get, set } from "./object-helpers.js";
const mergeResponses = (response1, response2) => {
if (Object.keys(response1).length === 0) {
return Object.assign(response1, response2);
}
const path = findPaginatedResourcePath(response1);
const nodesPath = [...path, "nodes"];
const newNodes = get(response2, nodesPath);
if (newNodes) {
set(response1, nodesPath, (values) => {
return [...values, ...newNodes];
});
}
const edgesPath = [...path, "edges"];
const newEdges = get(response2, edgesPath);
if (newEdges) {
set(response1, edgesPath, (values) => {
return [...values, ...newEdges];
});
}
const pageInfoPath = [...path, "pageInfo"];
set(response1, pageInfoPath, get(response2, pageInfoPath));
return response1;
};
export {
mergeResponses
};