MCPcopy Create free account
hub / github.com/codemix/graph / appendOrderDirection

Function appendOrderDirection

packages/graph/src/Traversals.ts:1470–1493  ·  view source on GitHub ↗
(
  steps: readonly Step<any>[],
  orderDirection: {
    key?: string;
    direction: OrderDirection;
  },
)

Source from the content-addressed store, hash-verified

1468 : never;
1469
1470function appendOrderDirection(
1471 steps: readonly Step<any>[],
1472 orderDirection: {
1473 key?: string;
1474 direction: OrderDirection;
1475 },
1476) {
1477 const nextSteps = [...steps];
1478 const orderStep =
1479 nextSteps.length > 0 && nextSteps[nextSteps.length - 1] instanceof OrderStep
1480 ? nextSteps[nextSteps.length - 1]
1481 : undefined;
1482
1483 if (!orderStep) {
1484 nextSteps.push(new OrderStep({ directions: [orderDirection] }));
1485 return nextSteps;
1486 }
1487
1488 nextSteps[nextSteps.length - 1] = orderStep.clone({
1489 directions: [...orderStep.config.directions, orderDirection],
1490 });
1491
1492 return nextSteps;
1493}
1494
1495type ResolveTraversalPathProperty<
1496 TSchema extends GraphSchema,

Callers 3

byMethod · 0.85
byMethod · 0.85
byMethod · 0.85

Calls 2

pushMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected