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

Method sum

packages/graph/src/Traversals.ts:201–210  ·  view source on GitHub ↗

* Sum a numeric property across all items in the path. * Non-numeric or missing values are ignored.

(propertyName: string)

Source from the content-addressed store, hash-verified

199 * Non-numeric or missing values are ignored.
200 */
201 public sum(propertyName: string): number {
202 let total = 0;
203 for (const step of this) {
204 const value = step.property(propertyName as never);
205 if (typeof value === "number") {
206 total += value;
207 }
208 }
209 return total;
210 }
211
212 /**
213 * Get a node in the path by label.

Callers 1

Calls 1

propertyMethod · 0.45

Tested by

no test coverage detected