@mmstack/primitives 21.8.3 → 21.8.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2021,7 +2021,9 @@ function effectiveKeys(arr, getKey, report) {
|
|
|
2021
2021
|
* when the list is reordered.
|
|
2022
2022
|
*
|
|
2023
2023
|
* @param source A `Signal<T[]>` or a function returning `T[]`.
|
|
2024
|
-
* @param mapFn The mapping function. Receives the item
|
|
2024
|
+
* @param mapFn The mapping function. Receives the item, its index as a Signal, and the
|
|
2025
|
+
* entry's key (the effective ordinal key when `duplicateKeys` is enabled, otherwise
|
|
2026
|
+
* the raw key) — stable for the lifetime of the mapped entry.
|
|
2025
2027
|
* @param options Optional configuration:
|
|
2026
2028
|
* - `onDestroy`: A callback invoked when a mapped item is removed from the array.
|
|
2027
2029
|
* - `key`: A custom key extractor for identity matching (e.g. `(item) => item.id`)
|
|
@@ -2098,7 +2100,7 @@ function keyArray(source, mapFn, options = {}) {
|
|
|
2098
2100
|
items[j] = item;
|
|
2099
2101
|
const indexSignal = signal(j, ...(ngDevMode ? [{ debugName: "indexSignal" }] : /* istanbul ignore next */ []));
|
|
2100
2102
|
newIndexes[j] = indexSignal;
|
|
2101
|
-
newMapped[j] = mapFn(item, indexSignal);
|
|
2103
|
+
newMapped[j] = mapFn(item, indexSignal, newKeys ? newKeys[j] : getKey(item));
|
|
2102
2104
|
}
|
|
2103
2105
|
}
|
|
2104
2106
|
else {
|
|
@@ -2151,7 +2153,7 @@ function keyArray(source, mapFn, options = {}) {
|
|
|
2151
2153
|
else {
|
|
2152
2154
|
const indexSignal = signal(j, ...(ngDevMode ? [{ debugName: "indexSignal" }] : /* istanbul ignore next */ []));
|
|
2153
2155
|
newIndexes[j] = indexSignal;
|
|
2154
|
-
newMapped[j] = mapFn(newItems[j], indexSignal);
|
|
2156
|
+
newMapped[j] = mapFn(newItems[j], indexSignal, kNew(j));
|
|
2155
2157
|
}
|
|
2156
2158
|
}
|
|
2157
2159
|
items.length = newLen;
|