( // eslint-disable-next-line @typescript-eslint/no-explicit-any array: any[], keyToCheck: string, )
| 120 | // Tremor hasOnlyOneValueForKey [v0.1.0] |
| 121 | |
| 122 | export function hasOnlyOneValueForKey( |
| 123 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 124 | array: any[], |
| 125 | keyToCheck: string, |
| 126 | ): boolean { |
| 127 | // eslint-disable-next-line @typescript-eslint/no-explicit-any |
| 128 | const val: any[] = [] |
| 129 | |
| 130 | for (const obj of array) { |
| 131 | if (Object.prototype.hasOwnProperty.call(obj, keyToCheck)) { |
| 132 | val.push(obj[keyToCheck]) |
| 133 | if (val.length > 1) { |
| 134 | return false |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | |
| 139 | return true |
| 140 | } |
no outgoing calls
no test coverage detected