* Sum a numeric property across all items in the path. * Non-numeric or missing values are ignored.
(propertyName: string)
| 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. |
no test coverage detected