|
|
|
@ -7,35 +7,27 @@ import * as w from './warnings.js';
|
|
|
|
|
import { capture_store_binding } from './reactivity/store.js';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param {() => any} collection
|
|
|
|
|
* @param {Array<any>} array
|
|
|
|
|
* @param {(item: any, index: number) => string} key_fn
|
|
|
|
|
* @returns {void}
|
|
|
|
|
*/
|
|
|
|
|
export function validate_each_keys(collection, key_fn) {
|
|
|
|
|
render_effect(() => {
|
|
|
|
|
const keys = new Map();
|
|
|
|
|
const maybe_array = collection();
|
|
|
|
|
const array = is_array(maybe_array)
|
|
|
|
|
? maybe_array
|
|
|
|
|
: maybe_array == null
|
|
|
|
|
? []
|
|
|
|
|
: Array.from(maybe_array);
|
|
|
|
|
const length = array.length;
|
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
|
const key = key_fn(array[i], i);
|
|
|
|
|
if (keys.has(key)) {
|
|
|
|
|
const a = String(keys.get(key));
|
|
|
|
|
const b = String(i);
|
|
|
|
|
export function validate_each_keys(array, key_fn) {
|
|
|
|
|
const keys = new Map();
|
|
|
|
|
const length = array.length;
|
|
|
|
|
for (let i = 0; i < length; i++) {
|
|
|
|
|
const key = key_fn(array[i], i);
|
|
|
|
|
if (keys.has(key)) {
|
|
|
|
|
const a = String(keys.get(key));
|
|
|
|
|
const b = String(i);
|
|
|
|
|
|
|
|
|
|
/** @type {string | null} */
|
|
|
|
|
let k = String(key);
|
|
|
|
|
if (k.startsWith('[object ')) k = null;
|
|
|
|
|
/** @type {string | null} */
|
|
|
|
|
let k = String(key);
|
|
|
|
|
if (k.startsWith('[object ')) k = null;
|
|
|
|
|
|
|
|
|
|
e.each_key_duplicate(a, b, k);
|
|
|
|
|
}
|
|
|
|
|
keys.set(key, i);
|
|
|
|
|
e.each_key_duplicate(a, b, k);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
keys.set(key, i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|