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