Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 42x 42x 42x 42x 42x 90x 90x 90x 90x 90x 90x 90x 90x 90x 90x 4x 4x 4x 90x 90x 86x 86x 90x 90x 42x 42x | import { UNINITIALIZED } from '../../../constants.js'; import { snapshot } from '../../shared/clone.js'; import { inspect_effect, validate_effect } from '../reactivity/effects.js'; /** * @param {() => any[]} get_value * @param {Function} [inspector] */ // eslint-disable-next-line no-console export function inspect(get_value, inspector = console.log) { validate_effect('$inspect'); let initial = true; inspect_effect(() => { /** @type {any} */ var value = UNINITIALIZED; // Capturing the value might result in an exception due to the inspect effect being // sync and thus operating on stale data. In the case we encounter an exception we // can bail-out of reporting the value. Instead we simply console.error the error // so at least it's known that an error occured, but we don't stop execution try { value = get_value(); } catch (error) { // eslint-disable-next-line no-console console.error(error); } if (value !== UNINITIALIZED) { inspector(initial ? 'init' : 'update', ...snapshot(value, true)); } initial = false; }); } |