(
input: undefined | null | {[key: string]: V; [key: number]: V} | ReadonlyMap<K, V>,
compareFn: ((a: KeyValue<K, V>, b: KeyValue<K, V>) => number) | null = defaultComparator,
)
| 116 | ): T extends object ? Array<KeyValue<keyof T, T[keyof T]>> : null; |
| 117 | |
| 118 | transform<K, V>( |
| 119 | input: undefined | null | {[key: string]: V; [key: number]: V} | ReadonlyMap<K, V>, |
| 120 | compareFn: ((a: KeyValue<K, V>, b: KeyValue<K, V>) => number) | null = defaultComparator, |
| 121 | ): Array<KeyValue<K, V>> | null { |
| 122 | ngDevMode && warnIfSignal('KeyValuePipe', input); |
| 123 | |
| 124 | if (!input || (!(input instanceof Map) && typeof input !== 'object')) { |
| 125 | return null; |
| 126 | } |
| 127 | |
| 128 | // make a differ for whatever type we've been passed in |
| 129 | this.differ ??= this.differs.find(input).create(); |
| 130 | |
| 131 | const differChanges: KeyValueChanges<K, V> | null = this.differ.diff(input as any); |
| 132 | const compareFnChanged = compareFn !== this.compareFn; |
| 133 | |
| 134 | if (differChanges) { |
| 135 | this.keyValues = []; |
| 136 | differChanges.forEachItem((r: KeyValueChangeRecord<K, V>) => { |
| 137 | this.keyValues.push(makeKeyValuePair(r.key, r.currentValue!)); |
| 138 | }); |
| 139 | } |
| 140 | if (differChanges || compareFnChanged) { |
| 141 | if (compareFn) { |
| 142 | this.keyValues.sort(compareFn); |
| 143 | } |
| 144 | this.compareFn = compareFn; |
| 145 | } |
| 146 | return this.keyValues; |
| 147 | } |
| 148 | } |
| 149 | |
| 150 | export function defaultComparator<K, V>( |
nothing calls this directly
no test coverage detected