All files / src/internal/client/dev inspect.js

100% Statements 20/20
100% Branches 4/4
100% Functions 1/1
100% Lines 18/18

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 192x 2x 2x 2x 2x 2x 2x 2x 2x 36x 36x 36x 36x 36x 72x 72x 36x 36x  
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(() => {
		inspector(initial ? 'init' : 'update', ...snapshot(get_value(), true));
		initial = false;
	});
}